ZQuest Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2025-08-01 10:38:16
Exec Total Coverage
Lines: 15618 21209 73.6%
Functions: 409 489 83.6%
Branches: 13762 23644 58.2%

Line Branch Exec Source
1 #include "base/general.h"
2 #include "base/handles.h"
3 #include "base/mapscr.h"
4 #include "base/util.h"
5 #include "base/zdefs.h"
6 #include "zc/maps.h"
7 #include "zc/replay.h"
8 #include "zc/zelda.h"
9
10 #include <optional>
11 #include <cstring>
12 #include <set>
13 #include <stdio.h>
14
15 #include "base/qrs.h"
16 #include "base/dmap.h"
17 #include "zc/hero.h"
18 #include "zc/guys.h"
19 #include "subscr.h"
20 #include "zc/maps.h"
21 #include "zc/replay.h"
22 #include "zc/zc_ffc.h"
23 #include "zc/zc_subscr.h"
24 #include "zc/decorations.h"
25 #include "gamedata.h"
26 #include "hero_tiles.h"
27 #include "zc/title.h"
28 #include "zc/ffscript.h"
29 #include "drawing.h"
30 #include "zc/combos.h"
31 #include "base/zc_math.h"
32 #include "user_object.h"
33 #include "slopes.h"
34 #include "zc/zc_sys.h"
35 #include "zinfo.h"
36 #include "base/misctypes.h"
37 #include "music_playback.h"
38 #include "iter.h"
39
40 extern refInfo playerScriptData;
41 #include "zscriptversion.h"
42 #include "particles.h"
43 #include <fmt/format.h>
44 #include "zc/render.h"
45 #include <array>
46
47 extern refInfo *ri; //= NULL;
48 extern int32_t(*stack)[MAX_STACK_SIZE];
49 extern portal mirror_portal;
50 using std::set;
51
52 extern int32_t skipcont;
53
54 extern int32_t draw_screen_clip_rect_x1;
55 extern int32_t draw_screen_clip_rect_x2;
56 extern int32_t draw_screen_clip_rect_y1;
57 extern int32_t draw_screen_clip_rect_y2;
58
59 int32_t hero_count = -1;
60 extern int32_t hero_animation_speed; //lower is faster animation
61 static int32_t z3step = 2;
62 416 static zfix hero_newstep(1.5);
63 416 static zfix hero_newstep_diag(1.5);
64 bool did_scripta=false;
65 bool did_scriptb=false;
66 bool did_scriptl=false;
67 byte lshift = 0;
68 int32_t dowpn = -1;
69 int32_t directItemA = -1;
70 int32_t directItemB = -1;
71 int32_t directItemX = -1;
72 int32_t directItemY = -1;
73 int32_t directWpn = -1;
74 int32_t whistleitem=-1;
75 extern int32_t script_hero_cset;
76
77 void playLevelMusic();
78
79 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
80
81 #define CANFORCEFACEUP (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
82 #define NO_GRIDLOCK (get_qr(qr_DISABLE_4WAY_GRIDLOCK)||get_qr(qr_NEW_HERO_MOVEMENT2))
83 #define STANDING_Z_STATE (standing_on_z<0?standing_on_z:(standing_on_z+z+fakez < 0 ? zslongToFix(2147483647) : standing_on_z+z+fakez))
84 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_qr(qr_BROKEN_Z3_ANIMATION))
85
86 47 bool item_error()
87 {
88
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 39 times.
47 if(QMisc.miscsfx[sfxERROR])
89 8 sfx(QMisc.miscsfx[sfxERROR]);
90 47 return false;
91 }
92 5458408 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
93 {
94
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 5457597 times.
5458408 if(check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
95 5457597 return false;
96 5458408 }
97
98 12399077 static inline bool platform_fallthrough(bool doslopecheck = true)
99 {
100
2/2
✓ Branch 0 taken 10579121 times.
✓ Branch 1 taken 1819956 times.
12399077 if (!getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
101 10579121 return false;
102
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819956 times.
1819956 if (get_qr(qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
104 return true;
105
106
3/4
✓ Branch 0 taken 33989 times.
✓ Branch 1 taken 1785967 times.
✓ Branch 2 taken 33989 times.
✗ Branch 3 not taken.
1819956 if (Hero.jumping < 0 && get_qr(qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS))
107 return true;
108
109
7/8
✓ Branch 0 taken 1819956 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 706 times.
✓ Branch 3 taken 1819250 times.
✓ Branch 4 taken 1819202 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 105 times.
✓ Branch 7 taken 1819851 times.
3639206 if (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)))
110 105 return true;
111
112 1819851 return false;
113 12399077 }
114
115 5497 static inline bool on_sideview_solid(zfix x, zfix y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
116 {
117
3/4
✓ Branch 0 taken 5497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4451 times.
✓ Branch 3 taken 1046 times.
5497 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, (slopesmisc == 3), true) < 0) return true;
118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4451 times.
4451 if(slopesmisc == 2) return false;
119
4/4
✓ Branch 0 taken 3579 times.
✓ Branch 1 taken 872 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3569 times.
4451 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
120 3569 mapscr* s = get_scr_for_world_xy(x, y);
121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3569 if (y>=world_h-16 && cur_screen>=0x70 && !(s->flags2&wfDOWN)) return true;
122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3569 if (platform_fallthrough() && !ignoreFallthrough) return false;
123
2/4
✓ Branch 0 taken 3569 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3569 times.
✗ Branch 3 not taken.
3569 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, false, true) < 0) return true;
124
6/6
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 243 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 3508 times.
3873 if (y.getInt() % 16 ==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
125 61 return true;
126 3508 return false;
127 5497 }
128
129 16694757 static inline bool on_sideview_solid_oldpos(sprite* obj, bool ignoreFallthrough = false, int32_t slopesmisc = 0, zfix xofs = 0, zfix yofs = 0)
130 {
131 16694757 zfix rx = obj->x+obj->hxofs+obj->sxofs+xofs, ry = obj->y+obj->hyofs+obj->syofs+yofs,
132 16694757 rw = obj->hit_width+obj->sxsz_ofs, rh = obj->hit_height+obj->sysz_ofs,
133 16694757 orx = obj->old_x+obj->hxofs+obj->sxofs, ory = obj->old_y+obj->hyofs+obj->syofs,
134 16694757 x = obj->x+xofs, y = obj->y+yofs;
135
4/4
✓ Branch 0 taken 2065998 times.
✓ Branch 1 taken 14628759 times.
✓ Branch 2 taken 2052634 times.
✓ Branch 3 taken 13364 times.
16694757 if(slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, (slopesmisc == 3), true, obj->slopeid) < 0)
136 13364 return true;
137
2/2
✓ Branch 0 taken 158055 times.
✓ Branch 1 taken 16523338 times.
16681393 if(slopesmisc == 2)
138 158055 return false;
139
4/4
✓ Branch 0 taken 12734378 times.
✓ Branch 1 taken 3788960 times.
✓ Branch 2 taken 337926 times.
✓ Branch 3 taken 12396452 times.
16523338 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1))
140 4126886 return true;
141
6/6
✓ Branch 0 taken 103114 times.
✓ Branch 1 taken 12293338 times.
✓ Branch 2 taken 6150 times.
✓ Branch 3 taken 96964 times.
✓ Branch 4 taken 5206 times.
✓ Branch 5 taken 944 times.
12396452 if (y>=world_h-16 && cur_screen>=0x70 && !(hero_scr->flags2&wfDOWN))
142 944 return true;
143
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 12395403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
12395508 if (platform_fallthrough() && !ignoreFallthrough) return false;
144
3/4
✓ Branch 0 taken 878415 times.
✓ Branch 1 taken 11516988 times.
✓ Branch 2 taken 878415 times.
✗ Branch 3 not taken.
12395403 if (slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, false, true, obj->slopeid) < 0)
145 return true;
146
6/6
✓ Branch 0 taken 9279794 times.
✓ Branch 1 taken 3115609 times.
✓ Branch 2 taken 885 times.
✓ Branch 3 taken 3114724 times.
✓ Branch 4 taken 885 times.
✓ Branch 5 taken 12394518 times.
15511012 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
147 885 return true;
148 12394518 return false;
149 16694757 }
150
151 103022 static inline bool no_plat_action()
152 {
153
5/8
✓ Branch 0 taken 103022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102724 times.
✓ Branch 3 taken 298 times.
✓ Branch 4 taken 102724 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 102724 times.
103022 if(Hero.fallclk || Hero.drownclk || toogam || Hero.getOnSideviewLadder())
154 298 return true;
155
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 102283 times.
102724 switch(Hero.action)
156 {
157 case freeze: case rafting: case inwind: case scrolling: case won: case hopping:
158 case climbcovertop: case climbcoverbottom: case dying: case drowning:
159 case falling: case lavadrowning: case sideswimfreeze: case sidedrowning:
160 441 return true;
161 }
162 102283 return false;
163 103022 }
164 84940 bool HeroClass::on_ffc_platform(ffcdata const& ffc, bool old)
165 {
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84940 times.
84940 if(no_plat_action())
167 return false;
168
2/2
✓ Branch 0 taken 45120 times.
✓ Branch 1 taken 39820 times.
84940 if(!get_qr(qr_MULTI_PLATFORM_FFC))
169 {
170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39820 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39820 if(platform_ffc && &ffc != platform_ffc)
171 return false;
172 39820 platform_ffc = nullptr;
173 39820 }
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84940 times.
84940 if(sideview_mode())
175 {
176 if((ffc.flags & (ffc_solid|ffc_platform|ffc_changer)) != (ffc_solid|ffc_platform))
177 return false;
178 zfix fx = old ? ffc.old_x : ffc.x, fy = old ? ffc.old_y : ffc.y;
179 static const zfix tol = 0.5_zf;
180 if((y+16-fy).getAbs() > tol)
181 return false;
182 if(fx > x+12)
183 return false;
184 if(fx+ffc.hit_width <= x+4)
185 return false;
186 }
187 else
188 {
189
2/2
✓ Branch 0 taken 84760 times.
✓ Branch 1 taken 180 times.
84940 if((ffc.flags & (ffc_platform|ffc_changer)) != ffc_platform)
190 84760 return false;
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(z)
192 return false;
193 static const int tol = 3;
194
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(!(old
195 180 ? ffc.collide_old(x + 8-tol, y + (bigHitbox ? 8 : 12), tol*2, tol*2)
196 : ffc.collide(x + 8-tol, y + (bigHitbox ? 8 : 12)-tol, tol*2, tol*2)))
197 180 return false;
198 }
199 platform_ffc = &ffc;
200 return true;
201 84940 }
202 18082 bool HeroClass::on_ffc_platform()
203 {
204
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 17343 times.
18082 if(no_plat_action())
205 739 return false;
206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17343 if(platform_ffc && on_ffc_platform(*platform_ffc,false))
207 return true;
208 119446 bool any_on_platform = find_ffc([&](const ffc_handle_t& ffc_handle) {
209 84760 return on_ffc_platform(*ffc_handle.ffc, false);
210 17343 }).has_value();
211 17343 return any_on_platform;
212 18082 }
213
214 14773158 void HeroClass::check_platform_ffc()
215 {
216
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14773158 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14773158 if(platform_ffc && !on_ffc_platform(*platform_ffc,false))
217 {
218 clear_platform_ffc();
219 on_ffc_platform();
220 }
221 14773158 }
222 37419 void HeroClass::clear_platform_ffc()
223 {
224 37419 platform_ffc = nullptr;
225 37419 }
226
227 2302 void HeroClass::snap_platform()
228 {
229
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 1292 times.
2302 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false, true) < 0)
230 1010 return;
231
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1292 if (y>=world_h-16 && cur_screen>=0x70 && !(hero_scr->flags2&wfDOWN))
232 {
233 y = world_h-16;
234 return;
235 }
236
4/4
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 385 times.
1292 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
237 385 return;
238 907 movexy(0,1,false,true,false,false);
239 2302 }
240
241
242 41174799 bool usingActiveShield(int32_t itmid)
243 {
244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41174799 times.
41174799 if(Hero.shieldjinxclk) return false;
245
2/2
✓ Branch 0 taken 5611971 times.
✓ Branch 1 taken 35562828 times.
41174799 switch(Hero.action) //filter allowed actions
246 {
247 case none: case walking: case rafting:
248 case gothit: case swimhit:
249 35562828 break;
250 5611971 default: return false;
251 }
252
4/4
✓ Branch 0 taken 12334 times.
✓ Branch 1 taken 35550494 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 8014 times.
35562828 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35554814 times.
35554814 if(itmid < 0)
254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35554814 times.
35554814 itmid = (Hero.active_shield_id < 0
255 35554814 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
256
2/2
✓ Branch 0 taken 31306877 times.
✓ Branch 1 taken 4247937 times.
35554814 if(itmid < 0) return false;
257 31306877 auto const& itm = itemsbuf[itmid];
258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306877 times.
31306877 if(item_disabled(itmid)) return false;
259
1/2
✓ Branch 0 taken 31306877 times.
✗ Branch 1 not taken.
31306877 if(!checkitem_jinx(itmid)) return false;
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306877 times.
31306877 if(!(itm.flags & item_flag9)) return false;
261 if(!isItmPressed(itmid))
262 {
263 byte intbtn = byte(itm.misc5&0xFF);
264 if(!itm.misc5 || !getIntBtnInput(intbtn, false, true, false, false, true))
265 return false;
266 }
267 return (checkbunny(itmid) && checkmagiccost(itmid));
268 41174799 }
269 4447061 int32_t getCurrentShield(bool requireActive)
270 {
271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4447061 times.
4447061 if(Hero.shieldjinxclk) return -1;
272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4447061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4447061 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
273 return Hero.active_shield_id;
274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4447061 times.
4447061 if(!requireActive) return current_item_id(itype_shield,false,true);
275 return -1;
276 4447061 }
277 625298 int32_t getCurrentActiveShield()
278 {
279 625298 int32_t id = Hero.active_shield_id;
280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 625298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
625298 if(id > -1 && usingActiveShield(id))
281 return id;
282 625298 return -1;
283 625298 }
284 14307783 int32_t refreshActiveShield()
285 {
286 14307783 int32_t id = -1;
287
2/2
✓ Branch 0 taken 14015059 times.
✓ Branch 1 taken 292724 times.
14307783 if(DrunkcBbtn())
288 {
289
2/2
✓ Branch 0 taken 290821 times.
✓ Branch 1 taken 1903 times.
292724 itemdata const& dat = itemsbuf[NEG_OR_MASK(Bwpn,0xFFF)];
290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292724 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292724 if(dat.family == itype_shield && (dat.flags & item_flag9))
291 {
292 id = NEG_OR_MASK(Bwpn,0xFFF);
293 }
294 292724 }
295
3/4
✓ Branch 0 taken 14307783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13066126 times.
✓ Branch 3 taken 1241657 times.
14307783 if(id < 0 && DrunkcAbtn())
296 {
297
2/2
✓ Branch 0 taken 1100142 times.
✓ Branch 1 taken 141515 times.
1241657 itemdata const& dat = itemsbuf[NEG_OR_MASK(Awpn,0xFFF)];
298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1241657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1241657 if(dat.family == itype_shield && (dat.flags & item_flag9))
299 {
300 id = NEG_OR_MASK(Awpn,0xFFF);
301 }
302 1241657 }
303
3/4
✓ Branch 0 taken 14307783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14295176 times.
✓ Branch 3 taken 12607 times.
14307783 if(id < 0 && DrunkcEx1btn())
304 {
305
2/2
✓ Branch 0 taken 2047 times.
✓ Branch 1 taken 10560 times.
12607 itemdata const& dat = itemsbuf[NEG_OR_MASK(Xwpn,0xFFF)];
306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12607 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12607 if(dat.family == itype_shield && (dat.flags & item_flag9))
307 {
308 id = NEG_OR_MASK(Xwpn,0xFFF);
309 }
310 12607 }
311
3/4
✓ Branch 0 taken 14307783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14305064 times.
✓ Branch 3 taken 2719 times.
14307783 if(id < 0 && DrunkcEx2btn())
312 {
313
2/2
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 236 times.
2719 itemdata const& dat = itemsbuf[NEG_OR_MASK(Ywpn,0xFFF)];
314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2719 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2719 if(dat.family == itype_shield && (dat.flags & item_flag9))
315 {
316 id = NEG_OR_MASK(Ywpn,0xFFF);
317 }
318 2719 }
319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307783 times.
14307783 if(id < 0)
320 {
321 14307783 auto shield_id = current_item_id(itype_shield,false,true);
322 14307783 itemdata const& dat = itemsbuf[shield_id];
323
3/4
✓ Branch 0 taken 12688591 times.
✓ Branch 1 taken 1619192 times.
✓ Branch 2 taken 12688591 times.
✗ Branch 3 not taken.
14307783 if(dat.family == itype_shield && (dat.flags & item_flag9))
324 {
325 byte intbtn = byte(dat.misc5&0xFF);
326 if(getIntBtnInput(intbtn, false, true, false, false, true))
327 id = shield_id;
328 }
329 14307783 }
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307783 times.
14307783 if(!usingActiveShield(id))
331 14307783 return -1;
332 return id;
333 14307783 }
334 static bool is_immobile()
335 {
336 if(!get_qr(qr_NEW_HERO_MOVEMENT))
337 return false;
338 zfix rate(Hero.steprate);
339 int32_t shieldid = getCurrentActiveShield();
340 if(shieldid > -1)
341 {
342 itemdata const& shield = itemsbuf[shieldid];
343 if(shield.flags & item_flag10) //Change Speed flag
344 {
345 zfix perc = shield.misc7;
346 perc /= 100;
347 if(perc < 0)
348 perc = (perc*-1)+1;
349 rate = (rate * perc) + shield.misc8;
350 }
351 }
352 return rate != 0;
353 }
354
355 28817076 bool nomove_action(int action)
356 {
357
2/2
✓ Branch 0 taken 27601633 times.
✓ Branch 1 taken 1215443 times.
28817076 switch(action)
358 {
359 case gothit:
360 case drowning:
361 case lavadrowning:
362 case sidedrowning:
363 case falling:
364 case freeze:
365 case sideswimfreeze:
366 case scrolling:
367 case casting:
368 case sideswimcasting:
369 case landhold1:
370 case landhold2:
371 case waterhold1:
372 case waterhold2:
373 case sidewaterhold1:
374 case sidewaterhold2:
375 case hopping:
376 case inwind:
377 1215443 return true;
378 }
379 27601633 return false;
380 28817076 }
381
382 14701813 bool HeroClass::isStanding(bool forJump)
383 {
384
3/4
✓ Branch 0 taken 14669982 times.
✓ Branch 1 taken 31831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14669982 times.
14701813 if(z || fakez) return false;
385
4/4
✓ Branch 0 taken 332206 times.
✓ Branch 1 taken 14337776 times.
✓ Branch 2 taken 4782 times.
✓ Branch 3 taken 161022 times.
14835786 if(isSideViewHero() && !on_sideview_solid_oldpos(this)
386
4/6
✓ Branch 0 taken 165804 times.
✓ Branch 1 taken 166402 times.
✓ Branch 2 taken 165804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 165804 times.
✗ Branch 5 not taken.
332206 && !ladderx && !laddery && !getOnSideviewLadder())
387 161022 return false;
388
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 14508924 times.
14508960 if(hoverclk) return false;
389
2/2
✓ Branch 0 taken 605130 times.
✓ Branch 1 taken 13903794 times.
14508924 if(nomove_action(action)) return false;
390 13903794 int32_t val = check_pitslide();
391
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 13903759 times.
13903794 if(val == -2) return false;
392
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 13903502 times.
13903759 if(val == -1) return true;
393 257 return forJump;
394 14701813 }
395 830180 bool HeroClass::isLifting()
396 {
397
2/2
✓ Branch 0 taken 11209 times.
✓ Branch 1 taken 818971 times.
830180 if(lift_wpn) return true;
398 818971 return false;
399 830180 }
400 62 void HeroClass::set_liftflags(int liftid)
401 {
402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(unsigned(liftid) >= MAXITEMS)
403 return;
404 62 itemdata const& itm = itemsbuf[liftid];
405
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 SETFLAG(liftflags, LIFTFL_DIS_SWIMMING, !(itm.flags & item_flag2));
406
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
62 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & item_flag3);
407
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
62 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & item_flag4);
408
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 SETFLAG(liftflags, LIFTFL_DROP_ON_HIT, itm.flags & item_flag5);
409 62 }
410
411 575099 void HeroClass::set_respawn_point(bool setwarp)
412 {
413 575099 zfix oldx = x, oldy = y;
414
2/2
✓ Branch 0 taken 44953 times.
✓ Branch 1 taken 530146 times.
575099 if (replay_version_check(17))
415 {
416 530146 x = vbound(x,0,world_w-16);
417 530146 y = vbound(y,0,world_h-16);
418 530146 }
419
420
2/2
✓ Branch 0 taken 557051 times.
✓ Branch 1 taken 18048 times.
575099 if(setwarp)
421 {
422 18048 warpx = x;
423 18048 warpy = y;
424 18048 raftwarpx = x;
425 18048 raftwarpy = y;
426 18048 }
427 575099 do
428 {
429
2/2
✓ Branch 0 taken 44460 times.
✓ Branch 1 taken 530639 times.
575099 if(!get_qr(qr_OLD_RESPAWN_POINTS))
430 {
431
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 530520 times.
530639 if(cur_screen >= 0x80) break;
432 530520 bool is_safe = true;
433
2/2
✓ Branch 0 taken 461042 times.
✓ Branch 1 taken 69478 times.
530520 switch(action)
434 {
435 case none: case walking:
436 461042 break;
437 default:
438 69478 is_safe = false;
439 69478 }
440
2/2
✓ Branch 0 taken 461042 times.
✓ Branch 1 taken 69478 times.
530520 if(!is_safe) break; //unsafe action
441
5/6
✓ Branch 0 taken 457693 times.
✓ Branch 1 taken 3349 times.
✓ Branch 2 taken 457693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 457674 times.
461042 if(z > 0 || fakez > 0 || hoverclk) break; //in air
442
4/4
✓ Branch 0 taken 5497 times.
✓ Branch 1 taken 452177 times.
✓ Branch 2 taken 1989 times.
✓ Branch 3 taken 3508 times.
457674 if(sideview_mode() && !on_sideview_solid(x,y,true)) break; //in air sideview
443
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 454026 times.
454166 if(check_pitslide(true) != -1) break; //On a pit
444
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 454015 times.
454026 if (ladderx+laddery) break; //on the ladder
445
446 { //Check water
447 454015 int32_t water = 0;
448 454015 int32_t types[4] = {0};
449 454015 int32_t x1 = x+4, x2 = x+11,
450 454015 y1 = y+9, y2 = y+15;
451
1/2
✓ Branch 0 taken 454015 times.
✗ Branch 1 not taken.
454015 if (get_qr(qr_SMARTER_WATER))
452 {
453
4/4
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 452110 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 249 times.
454277 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
454
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 748 times.
1905 iswaterex_z3(0, -1, x1, y2, true, false) &&
455
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 895 times.
1157 iswaterex_z3(0, -1, x2, y1, true, false) &&
456 262 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
457 454015 }
458 else
459 {
460 types[0] = COMBOTYPE(x1,y1);
461
462 if(MAPFFCOMBO(x1,y1))
463 types[0] = FFCOMBOTYPE(x1,y1);
464
465 types[1] = COMBOTYPE(x1,y2);
466
467 if(MAPFFCOMBO(x1,y2))
468 types[1] = FFCOMBOTYPE(x1,y2);
469
470 types[2] = COMBOTYPE(x2,y1);
471
472 if(MAPFFCOMBO(x2,y1))
473 types[2] = FFCOMBOTYPE(x2,y1);
474
475 types[3] = COMBOTYPE(x2,y2);
476
477 if(MAPFFCOMBO(x2,y2))
478 types[3] = FFCOMBOTYPE(x2,y2);
479
480 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
481 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
482 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
483
484 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
485 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
486 water = typec;
487 }
488
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 453766 times.
454015 if(water > 0)
489 249 break;
490 } //End check water
491
492 2268830 rpos_t rposes[] = {
493 453766 COMBOPOS_REGION_B(x,y+(bigHitbox?0:8)),
494 453766 COMBOPOS_REGION_B(x,y+15),
495 453766 COMBOPOS_REGION_B(x+15,y+(bigHitbox?0:8)),
496 453766 COMBOPOS_REGION_B(x+15,y+15)
497 };
498
2/2
✓ Branch 0 taken 411496 times.
✓ Branch 1 taken 1697129 times.
2108625 for(auto rpos : rposes)
499 {
500
2/2
✓ Branch 0 taken 1697065 times.
✓ Branch 1 taken 64 times.
1697129 if (rpos == rpos_t::None)
501 64 continue;
502
503
2/2
✓ Branch 0 taken 1654795 times.
✓ Branch 1 taken 42270 times.
1697065 if(HASFLAG_ANY(mfUNSAFEGROUND, rpos)) //"Unsafe Ground" flag touching the player
504 {
505 42270 is_safe = false;
506 42270 break;
507 }
508 }
509
2/2
✓ Branch 0 taken 411496 times.
✓ Branch 1 taken 42270 times.
453766 if(!is_safe) break;
510 411496 }
511 455956 respawn_x = x;
512 455956 respawn_y = y;
513 455956 respawn_scr = cur_screen;
514 455956 respawn_dmap = cur_dmap;
515 455956 }
516 while(false); //run once, but 'break' works
517
518 575099 x = oldx;
519 575099 y = oldy;
520 575099 }
521
522 366154 void HeroClass::clear_ice()
523 {
524 366154 ice_vx = ice_vy = 0;
525 366154 ice_entry_count = ice_entry_mcount = 0;
526 366154 ice_combo = 0;
527 366154 sliding = 0;
528 366154 }
529 5 void HeroClass::force_ice_velocity(optional<zfix> vx, optional<zfix> vy)
530 {
531 5 auto ic = ice_combo;
532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(script_ice_combo)
533 {
534
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
535 5 ic = script_ice_combo;
536 else ic = 0;
537 5 }
538
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!ic) return;
539
540 5 auto const& icecmb = combobuf[ic];
541
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 if(script_ice_combo && ic && !sliding)
542 {
543 //Special case to prevent the forced vx/vy from being overwritten
544 5 sliding = 1;
545 5 ice_vx = ice_vy = 0;
546 5 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
547 5 }
548
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(vx) ice_vx = vbound(*vx, -cap, cap);
550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(vy) ice_vy = vbound(*vy, -cap, cap);
551 5 }
552 145 void HeroClass::go_respawn_point()
553 {
554 145 x = respawn_x;
555 145 y = respawn_y;
556 145 clear_ice();
557 145 handle_portal_prox(&mirror_portal);
558
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 portals.forEach([&](sprite& p)
559 {
560 handle_portal_prox((portal*)&p);
561 return false;
562 });
563 145 warpx=x;
564 145 warpy=y;
565 145 raftwarpx = x;
566 145 raftwarpy = y;
567 145 trySideviewLadder(); //Cling to ladder automatically
568
569
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 70 times.
145 if(get_qr(qr_OLD_RESPAWN_POINTS))
570 70 return; //No cross-screen return
571
572
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(cur_dmap != respawn_dmap || cur_screen != respawn_scr)
573 {
574 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr-DMaps[cur_dmap].xoff,
575 -1, -1, 0, 0, warpFlagNOSTEPFORWARD, -1);
576 }
577 145 }
578
579 33768 void HeroClass::trySideviewLadder()
580 {
581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33768 if(canSideviewLadder() && !on_sideview_solid_oldpos(this))
582 setOnSideviewLadder(true);
583 33768 }
584
585 52369515 bool HeroClass::can_pitfall(bool ignore_hover)
586 {
587 52369515 return !(
588 52369515 isSideViewGravity()
589
2/2
✓ Branch 0 taken 51614152 times.
✓ Branch 1 taken 755363 times.
52369515 || action==rafting
590
7/8
✓ Branch 0 taken 51387417 times.
✓ Branch 1 taken 226735 times.
✓ Branch 2 taken 51349766 times.
✓ Branch 3 taken 37651 times.
✓ Branch 4 taken 51349766 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51348668 times.
✓ Branch 7 taken 1098 times.
51614152 || z>0 || fakez>0 || fall<0 || fakefall<0
591
3/4
✓ Branch 0 taken 51348668 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 51348615 times.
51348668 || (hoverclk && !ignore_hover)
592
6/6
✓ Branch 0 taken 51325642 times.
✓ Branch 1 taken 23026 times.
✓ Branch 2 taken 51322984 times.
✓ Branch 3 taken 2658 times.
✓ Branch 4 taken 51305501 times.
✓ Branch 5 taken 17483 times.
51348668 || inlikelike || inwallm || pull_hero || toogam
593
6/6
✓ Branch 0 taken 51232673 times.
✓ Branch 1 taken 72828 times.
✓ Branch 2 taken 50735952 times.
✓ Branch 3 taken 496721 times.
✓ Branch 4 taken 50735728 times.
✓ Branch 5 taken 224 times.
51305501 || (ladderx||laddery) || getOnSideviewLadder()
594
3/4
✓ Branch 0 taken 50735728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50729382 times.
✓ Branch 3 taken 6346 times.
50735728 || drownclk || !(moveflags & move_can_pitfall)
595
2/2
✓ Branch 0 taken 50728819 times.
✓ Branch 1 taken 563 times.
50729382 || platform_ffc);
596 }
597
598 8430101 int32_t HeroClass::DrunkClock()
599 {
600 8430101 return drunkclk;
601 }
602 1 void HeroClass::setDrunkClock(int32_t newdrunkclk)
603 {
604 1 drunkclk=newdrunkclk;
605 1 }
606
607 440770 int32_t HeroClass::StunClock()
608 {
609 440770 return lstunclock;
610 }
611 378 void HeroClass::setStunClock(int32_t v)
612 {
613 378 lstunclock=v;
614 378 }
615
616 3189193716 int32_t HeroClass::BunnyClock()
617 {
618 3189193716 return lbunnyclock;
619 }
620 void HeroClass::setBunnyClock(int32_t v)
621 {
622 lbunnyclock=v;
623 }
624
625
13/26
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 416 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 416 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 416 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 416 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 416 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 416 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 416 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 416 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 416 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 416 times.
✗ Branch 25 not taken.
832 HeroClass::HeroClass() : sprite()
626 416 {
627 416 lift_wpn = nullptr;
628
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 init();
629 416 }
630
631 //2.6
632
633 //Stop the subscreen from falling. -Z
634
635 1383 bool HeroClass::stopSubscreenFalling(){
636 1383 return preventsubscreenfalling;
637 }
638
639 void HeroClass::stopSubscreenFalling(bool v){
640 preventsubscreenfalling = v;
641 }
642
643 14309406 void HeroClass::ClearhitHeroUIDs()
644 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
645 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
646 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
647 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
648 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
649 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
650 //clear it on the next frame, but that had the SAME outcome.
651 //Where and how can I clear a value at the end of every frame, so that:
652 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
653 // 2. FFCs can read it before Waitframe. --same.
654 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
655
2/2
✓ Branch 0 taken 243259902 times.
✓ Branch 1 taken 14309406 times.
257569308 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
656 {
657 /*
658 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
659 {
660 //Z_scripterrlog("frame is: %d\n", frame);
661 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
662 lastHitBy[q][0] = 0;
663 }
664 */
665 243259902 lastHitBy[q][0] = 0;
666 243259902 }
667 14309406 }
668
669 77142 void HeroClass::sethitHeroUID(int32_t type, int32_t screen)
670 {
671 77142 lastHitBy[type][0] = screen;
672 77142 }
673
674 3244 int32_t HeroClass::gethitHeroUID(int32_t type)
675 {
676 3244 return lastHitBy[type][0];
677 }
678
679 void HeroClass::set_defence(int32_t type, int32_t v)
680 {
681 defence[type] = v;
682 }
683
684 int32_t HeroClass::get_defence(int32_t type)
685 {
686 return defence[type];
687 }
688
689
690 //Set Hero;s hurt sfx
691 277656 void HeroClass::setHurtSFX(int32_t sfx)
692 {
693 277656 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
694 277656 }
695 15551 int32_t HeroClass::getHurtSFX()
696 {
697 15551 return QMisc.miscsfx[sfxHURTPLAYER];
698 }
699
700 bool HeroClass::getDiagMove()
701 {
702 return diagonalMovement;
703 }
704 1122 void HeroClass::setDiagMove(bool newdiag)
705 {
706 1122 diagonalMovement=newdiag;
707 1122 }
708 271788 bool HeroClass::getBigHitbox()
709 {
710 271788 return bigHitbox;
711 }
712 2681 void HeroClass::setBigHitbox(bool newbigHitbox)
713 {
714 2681 bigHitbox=newbigHitbox;
715 2681 syofs = bigHitbox?0:8;
716 2681 sysz_ofs = bigHitbox?0:-8;
717 2681 }
718 6376 int32_t HeroClass::getStepRate()
719 {
720 6376 return steprate;
721 }
722 952 void HeroClass::setStepRate(int32_t newrate)
723 {
724 952 steprate = newrate;
725 952 }
726 int32_t HeroClass::getSwimUpRate()
727 {
728 return game->get_sideswim_up();
729 }
730 void HeroClass::setSwimUpRate(int32_t newrate)
731 {
732 game->set_sideswim_up(newrate);
733 }
734 int32_t HeroClass::getSwimSideRate()
735 {
736 return game->get_sideswim_side();
737 }
738 void HeroClass::setSwimSideRate(int32_t newrate)
739 {
740 game->set_sideswim_side(newrate);
741 }
742 int32_t HeroClass::getSwimDownRate()
743 {
744 return game->get_sideswim_down();
745 }
746 void HeroClass::setSwimDownRate(int32_t newrate)
747 {
748 game->set_sideswim_down(newrate);
749 }
750
751
752 10524533 void HeroClass::herostep()
753 {
754
2/2
✓ Branch 0 taken 9866563 times.
✓ Branch 1 taken 657970 times.
10524533 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
755 //need to run all global/hero/dmap scripts here?
756 10524533 }
757
758 142451 bool is_moving()
759 {
760
6/6
✓ Branch 0 taken 110147 times.
✓ Branch 1 taken 32304 times.
✓ Branch 2 taken 82023 times.
✓ Branch 3 taken 28124 times.
✓ Branch 4 taken 32573 times.
✓ Branch 5 taken 49450 times.
142451 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
761 }
762
763 // called by ALLOFF()
764 36451 void HeroClass::resetflags(bool all)
765 {
766 36451 refilling=REFILL_NONE;
767 36451 inwallm=false;
768 36451 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
769 36451 usecounts.clear();
770
771
4/4
✓ Branch 0 taken 36367 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 35939 times.
36451 if(swordclk>0 || all)
772 {
773 512 swordclk=0;
774 512 verifyAWpn();
775 512 }
776
4/4
✓ Branch 0 taken 36430 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 36002 times.
36451 if(itemclk>0 || all)
777 449 itemclk=0;
778
3/4
✓ Branch 0 taken 36451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 36023 times.
36451 if(shieldjinxclk>0 || all)
779 428 shieldjinxclk=0;
780
781
2/2
✓ Branch 0 taken 36023 times.
✓ Branch 1 taken 428 times.
36451 if(all)
782 {
783 428 DivineProtectionShieldClk=0;
784
785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428 times.
428 if(div_prot_item != -1)
786 {
787 stop_sfx(itemsbuf[div_prot_item].usesound);
788 stop_sfx(itemsbuf[div_prot_item].usesound+1);
789 }
790
791 428 div_prot_item = -1;
792 428 hoverclk=jumping=0;
793 428 hoverflags = 0;
794 428 }
795 36451 damageovertimeclk = 0;
796 36451 newconveyorclk = 0;
797 36451 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
798
2/2
✓ Branch 0 taken 36451 times.
✓ Branch 1 taken 255157 times.
291608 for(auto q = 0; q < 7; ++q)
799 255157 hooked_undercombos[q] = -1;
800 36451 hopclk=0;
801 36451 hopdir=-1;
802 36451 attackclk=0;
803 36451 stomping=false;
804 36451 reset_swordcharge();
805 36451 diveclk=drownclk=drownCombo=0;
806 36451 action=none; FFCore.setHeroAction(none);
807 36451 conveyor_flags=0;
808 36451 magiccastclk=0;
809 36451 magicitem=-1;
810 36451 }
811
812 //Can use this for Hero->Stun. -Z
813 14701 void HeroClass::Freeze()
814 {
815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14701 times.
14701 if (action != inwind)
816 {
817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14701 times.
14701 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
818 14701 else {action=freeze; FFCore.setHeroAction(freeze);}
819 // also cancel Hero's attack
820 14701 attackclk = 0;
821 14701 }
822 14701 }
823 3744 void HeroClass::unfreeze()
824 {
825
4/4
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 2456 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 1 times.
3744 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3744 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3744 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
827 3744 }
828
829 194 void HeroClass::Drown(int32_t state)
830 {
831 // Hero should never drown if the ladder is out
832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 if(ladderx+laddery)
833 return;
834
835 194 drop_liftwpn();
836
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 4 times.
194 switch(state)
837 {
838 case 1:
839 4 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
840 4 attackclk=0;
841 4 attack=wNone;
842 4 attackid=-1;
843 4 reset_swordcharge();
844 4 drownclk=64;
845 4 z=fakez=fall=fakefall=0;
846 4 break;
847
848
849 default:
850 {
851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (isSideViewHero() && get_qr(qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
852 190 else {action=drowning; FFCore.setHeroAction(drowning);}
853 190 attackclk=0;
854 190 attack=wNone;
855 190 attackid=-1;
856 190 reset_swordcharge();
857 190 drownclk=64;
858 190 z=fakez=fall=fakefall=0;
859 190 break;
860 }
861 }
862
863 194 }
864
865 2410 void HeroClass::finishedmsg()
866 {
867 //these are to cancel out any keys that Hero may
868 //be pressing so he doesn't attack at the end of
869 //a message if he was scrolling through it quickly.
870 2410 rAbtn();
871 2410 rBbtn();
872 2410 unfreeze();
873
874
3/4
✓ Branch 0 taken 2308 times.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2277 times.
4687 if(action == landhold1 ||
875
2/2
✓ Branch 0 taken 2279 times.
✓ Branch 1 taken 29 times.
2308 action == landhold2 ||
876
2/2
✓ Branch 0 taken 2278 times.
✓ Branch 1 taken 1 times.
2279 action == waterhold1 ||
877
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 1 times.
2278 action == waterhold2 ||
878
1/2
✓ Branch 0 taken 2277 times.
✗ Branch 1 not taken.
2277 action == sidewaterhold1 ||
879 2277 action == sidewaterhold2)
880 {
881 133 holdclk = 1;
882 133 }
883 2410 }
884 78 void HeroClass::setEaten(int32_t i)
885 {
886 78 inlikelike=i;
887 78 }
888 70 int32_t HeroClass::getEaten()
889 {
890 70 return inlikelike;
891 }
892 62953331 zfix HeroClass::getX()
893 {
894 62953331 return x;
895 }
896 63326333 zfix HeroClass::getY()
897 {
898 63326333 return y;
899 }
900 90480727 zfix HeroClass::getZ()
901 {
902 90480727 return z;
903 }
904 55596281 zfix HeroClass::getFakeZ()
905 {
906 55596281 return fakez;
907 }
908 zfix HeroClass::getFall()
909 {
910 return fall;
911 }
912 741274 zfix HeroClass::getJump()
913 {
914 741274 return fall / -100;
915 }
916 zfix HeroClass::getFakeFall()
917 {
918 return fakefall;
919 }
920 zfix HeroClass::getFakeJump()
921 {
922 return fakefall / -100;
923 }
924 zfix HeroClass::getXOfs()
925 {
926 return xofs;
927 }
928 1344 zfix HeroClass::getYOfs()
929 {
930 1344 return yofs;
931 }
932 void HeroClass::setXOfs(int32_t newxofs)
933 {
934 xofs=newxofs;
935 }
936 void HeroClass::setYOfs(int32_t newyofs)
937 {
938 yofs=newyofs;
939 }
940 int32_t HeroClass::getHXOfs()
941 {
942 return hxofs;
943 }
944 int32_t HeroClass::getHYOfs()
945 {
946 return hyofs;
947 }
948 int32_t HeroClass::getHXSz()
949 {
950 return hit_width;
951 }
952 int32_t HeroClass::getHYSz()
953 {
954 return hit_height;
955 }
956 88384 zfix HeroClass::getClimbCoverX()
957 {
958 88384 return climb_cover_x;
959 }
960 88384 zfix HeroClass::getClimbCoverY()
961 {
962 88384 return climb_cover_y;
963 }
964 int32_t HeroClass::getLadderX()
965 {
966 return ladderx;
967 }
968 int32_t HeroClass::getLadderY()
969 {
970 return laddery;
971 }
972
973 462621 void HeroClass::setX(int32_t new_x)
974 {
975 462621 zfix dx=new_x-x;
976 462621 justmoved = 2;
977
2/2
✓ Branch 0 taken 462600 times.
✓ Branch 1 taken 21 times.
462621 if(Lwpns.idFirst(wHookshot)>-1)
978 {
979 21 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
980 21 hs_startx+=(int32_t)dx;
981 21 }
982
983
2/2
✓ Branch 0 taken 462600 times.
✓ Branch 1 taken 21 times.
462621 if(Lwpns.idFirst(wHSHandle)>-1)
984 {
985 21 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
986 21 }
987
988
2/2
✓ Branch 0 taken 462612 times.
✓ Branch 1 taken 9 times.
462621 if(chainlinks.Count()>0)
989 {
990
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 9 times.
28 for(int32_t j=0; j<chainlinks.Count(); j++)
991 {
992 19 chainlinks.spr(j)->x+=dx;
993 19 }
994 9 }
995
996 462621 x=new_x;
997
998 // A kludge
999
4/4
✓ Branch 0 taken 3710 times.
✓ Branch 1 taken 458911 times.
✓ Branch 2 taken 2385 times.
✓ Branch 3 taken 1325 times.
462621 if(!diagonalMovement && dir<=down)
1000 1325 is_on_conveyor = -1;
1001 462621 }
1002
1003 482942 void HeroClass::setY(int32_t new_y)
1004 {
1005 482942 zfix dy=new_y-y;
1006 482942 justmoved = 2;
1007
2/2
✓ Branch 0 taken 482933 times.
✓ Branch 1 taken 9 times.
482942 if(Lwpns.idFirst(wHookshot)>-1)
1008 {
1009 9 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1010 9 hs_starty+=(int32_t)dy;
1011 9 }
1012
1013
2/2
✓ Branch 0 taken 482933 times.
✓ Branch 1 taken 9 times.
482942 if(Lwpns.idFirst(wHSHandle)>-1)
1014 {
1015 9 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1016 9 }
1017
1018
1/2
✓ Branch 0 taken 482942 times.
✗ Branch 1 not taken.
482942 if(chainlinks.Count()>0)
1019 {
1020 for(int32_t j=0; j<chainlinks.Count(); j++)
1021 {
1022 chainlinks.spr(j)->y+=dy;
1023 }
1024 }
1025
1026 482942 y=new_y;
1027
1028 // A kludge
1029
4/4
✓ Branch 0 taken 3710 times.
✓ Branch 1 taken 479232 times.
✓ Branch 2 taken 1325 times.
✓ Branch 3 taken 2385 times.
482942 if(!diagonalMovement && dir>=left)
1030 2385 is_on_conveyor = -1;
1031 482942 }
1032
1033 4 void HeroClass::setZ(int32_t new_z)
1034 {
1035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(isSideViewHero())
1036 return;
1037
1038
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(z==0 && new_z > 0)
1039 {
1040
1/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 switch(action)
1041 {
1042 case swimming:
1043 {
1044 diveclk=0;
1045 action=walking; FFCore.setHeroAction(walking);
1046 break;
1047 }
1048
1049 case waterhold1:
1050 {
1051 action=landhold1; FFCore.setHeroAction(landhold1);
1052 break;
1053 }
1054
1055 case waterhold2:
1056 {
1057 action=landhold2; FFCore.setHeroAction(landhold2);
1058 break;
1059 }
1060
1061 default:
1062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(charging) //!DIMITODO: Let Hero jump while charging sword
1063 {
1064 reset_swordcharge();
1065 attackclk=0;
1066 }
1067
1068 4 break;
1069 }
1070 4 }
1071
1072
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 z=(new_z>0 ? new_z : 0);
1073 4 }
1074
1075 void HeroClass::setFakeZ(int32_t new_z)
1076 {
1077 if(isSideViewHero())
1078 return;
1079
1080 if(fakez==0 && new_z > 0)
1081 {
1082 switch(action)
1083 {
1084 case swimming:
1085 {
1086 diveclk=0;
1087 action=walking; FFCore.setHeroAction(walking);
1088 break;
1089 }
1090
1091 case waterhold1:
1092 {
1093 action=landhold1; FFCore.setHeroAction(landhold1);
1094 break;
1095 }
1096
1097 case waterhold2:
1098 {
1099 action=landhold2; FFCore.setHeroAction(landhold2);
1100 break;
1101 }
1102
1103 default:
1104 if(charging) //!DIMITODO: Let Hero jump while charging sword
1105 {
1106 reset_swordcharge();
1107 attackclk=0;
1108 }
1109
1110 break;
1111 }
1112 }
1113
1114 fakez=(new_z>0 ? new_z : 0);
1115 }
1116
1117 25176 void HeroClass::setXfix(zfix new_x)
1118 {
1119 //Z_scripterrlog("setxdbl: %f\n",new_x);
1120 25176 zfix dx=new_x-x;
1121 25176 justmoved = 2;
1122
2/2
✓ Branch 0 taken 25166 times.
✓ Branch 1 taken 10 times.
25176 if(Lwpns.idFirst(wHookshot)>-1)
1123 {
1124 10 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
1125 10 hs_startx+=(int32_t)dx;
1126 10 }
1127
1128
2/2
✓ Branch 0 taken 25166 times.
✓ Branch 1 taken 10 times.
25176 if(Lwpns.idFirst(wHSHandle)>-1)
1129 {
1130 10 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
1131 10 }
1132
1133
2/2
✓ Branch 0 taken 25169 times.
✓ Branch 1 taken 7 times.
25176 if(chainlinks.Count()>0)
1134 {
1135
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for(int32_t j=0; j<chainlinks.Count(); j++)
1136 {
1137 15 chainlinks.spr(j)->x+=dx;
1138 15 }
1139 7 }
1140
1141 25176 x=new_x;
1142
1143 // A kludge
1144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25176 if(!diagonalMovement && dir<=down)
1145 is_on_conveyor = -1;
1146 25176 }
1147
1148 24356 void HeroClass::setYfix(zfix new_y)
1149 {
1150 24356 zfix dy=new_y-y;
1151 24356 justmoved = 2;
1152
2/2
✓ Branch 0 taken 24316 times.
✓ Branch 1 taken 40 times.
24356 if(Lwpns.idFirst(wHookshot)>-1)
1153 {
1154 40 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1155 40 hs_starty+=(int32_t)dy;
1156 40 }
1157
1158
2/2
✓ Branch 0 taken 24316 times.
✓ Branch 1 taken 40 times.
24356 if(Lwpns.idFirst(wHSHandle)>-1)
1159 {
1160 40 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1161 40 }
1162
1163
2/2
✓ Branch 0 taken 24322 times.
✓ Branch 1 taken 34 times.
24356 if(chainlinks.Count()>0)
1164 {
1165
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 34 times.
213 for(int32_t j=0; j<chainlinks.Count(); j++)
1166 {
1167 179 chainlinks.spr(j)->y+=dy;
1168 179 }
1169 34 }
1170
1171 24356 y=new_y;
1172
1173 // A kludge
1174
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24356 if(!diagonalMovement && dir>=left)
1175 is_on_conveyor = -1;
1176 24356 }
1177
1178 2779 void HeroClass::setZfix(zfix new_z)
1179 {
1180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2779 times.
2779 if(isSideViewHero())
1181 return;
1182
1183
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2758 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 15 times.
2779 if(z==0 && new_z > 0)
1184 {
1185
1/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 switch(action)
1186 {
1187 case swimming:
1188 {
1189 diveclk=0;
1190 action=walking; FFCore.setHeroAction(walking);
1191 break;
1192 }
1193
1194 case waterhold1:
1195 {
1196 action=landhold1; FFCore.setHeroAction(landhold1);
1197 break;
1198 }
1199
1200 case waterhold2:
1201 {
1202 action=landhold2; FFCore.setHeroAction(landhold2);
1203 break;
1204 }
1205
1206 default:
1207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(charging) //!DIMITODO: Let Hero jump while charging sword
1208 {
1209 reset_swordcharge();
1210 attackclk=0;
1211 }
1212
1213 15 break;
1214 }
1215 15 }
1216
1217
2/2
✓ Branch 0 taken 2771 times.
✓ Branch 1 taken 8 times.
2779 z=(new_z>0 ? new_z : 0_zf);
1218 2779 }
1219
1220 void HeroClass::setFakeZfix(zfix new_z)
1221 {
1222 if(isSideViewHero())
1223 return;
1224
1225 if(fakez==0 && new_z > 0)
1226 {
1227 switch(action)
1228 {
1229 case swimming:
1230 {
1231 diveclk=0;
1232 action=walking; FFCore.setHeroAction(walking);
1233 break;
1234 }
1235
1236 case waterhold1:
1237 {
1238 action=landhold1; FFCore.setHeroAction(landhold1);
1239 break;
1240 }
1241
1242 case waterhold2:
1243 {
1244 action=landhold2; FFCore.setHeroAction(landhold2);
1245 break;
1246 }
1247
1248 default:
1249 if(charging) //!DIMITODO: Let Hero jump while charging sword
1250 {
1251 reset_swordcharge();
1252 attackclk=0;
1253 }
1254
1255 break;
1256 }
1257 }
1258
1259 fakez=(new_z>0 ? new_z : 0_zf);
1260 }
1261
1262 77190 void HeroClass::setFall(zfix new_fall)
1263 {
1264 77190 fall=new_fall;
1265 77190 justmoved = 2;
1266 77190 jumping=-1;
1267 77190 }
1268 void HeroClass::setFakeFall(zfix new_fall)
1269 {
1270 fakefall=new_fall;
1271 jumping=-1;
1272 }
1273 76838 void HeroClass::setJump(zfix new_jump)
1274 {
1275 76838 setFall(new_jump*-100);
1276 76838 }
1277 void HeroClass::setFakeJump(zfix new_jump)
1278 {
1279 setFakeFall(new_jump*-100);
1280 }
1281 void HeroClass::setClimbCoverX(int32_t new_x)
1282 {
1283 climb_cover_x=new_x;
1284 }
1285 void HeroClass::setClimbCoverY(int32_t new_y)
1286 {
1287 climb_cover_y=new_y;
1288 }
1289 138971 int32_t HeroClass::getLStep()
1290 {
1291 138971 return lstep;
1292 }
1293 5804 int32_t HeroClass::getCharging()
1294 {
1295 5804 return charging;
1296 }
1297 127714 bool HeroClass::isCharged()
1298 {
1299 127714 return spins>0;
1300 }
1301 2 int32_t HeroClass::getAttackClk()
1302 {
1303 2 return attackclk;
1304 }
1305 2 void HeroClass::setAttackClk(int32_t new_clk)
1306 {
1307 2 attackclk=new_clk;
1308 2 }
1309 void HeroClass::setCharging(int32_t new_charging)
1310 {
1311 charging=new_charging;
1312 }
1313 2981682247 int32_t HeroClass::getSwordClk()
1314 {
1315 2981682247 return swordclk;
1316 }
1317 2914396127 int32_t HeroClass::getItemClk()
1318 {
1319 2914396127 return itemclk;
1320 }
1321 2928539572 int32_t HeroClass::getShieldClk()
1322 {
1323 2928539572 return shieldjinxclk;
1324 }
1325 720 void HeroClass::setSwordClk(int32_t newclk)
1326 {
1327 720 swordclk=newclk;
1328 720 verifyAWpn();
1329 720 }
1330 5880 void HeroClass::setItemClk(int32_t newclk)
1331 {
1332 5880 itemclk=newclk;
1333 5880 }
1334 2 void HeroClass::setShieldClk(int32_t newclk)
1335 {
1336 2 shieldjinxclk=newclk;
1337 2 }
1338 // TODO remove, no longer needed.
1339 1165909 zfix HeroClass::getModifiedX()
1340 {
1341 1165909 zfix tempx=x;
1342 1165909 return tempx;
1343 }
1344
1345 1165909 zfix HeroClass::getModifiedY()
1346 {
1347 1165909 zfix tempy=y;
1348 1165909 return tempy;
1349 }
1350
1351 64175 int32_t HeroClass::getDir()
1352 {
1353 64175 return dir;
1354 }
1355 95580 void HeroClass::setDir(int32_t newdir)
1356 {
1357 95580 dir=newdir;
1358 95580 reset_hookshot();
1359 95580 }
1360 441276 int32_t HeroClass::getHitDir()
1361 {
1362 441276 return hitdir;
1363 }
1364 2220 void HeroClass::setHitDir(int32_t newdir)
1365 {
1366 2220 hitdir = newdir;
1367 2220 }
1368 int32_t HeroClass::getClk()
1369 {
1370 return clk;
1371 }
1372 180367 int32_t HeroClass::getPushing()
1373 {
1374 180367 return pushing;
1375 }
1376 15591 void HeroClass::Catch()
1377 {
1378
5/6
✓ Branch 0 taken 15591 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12611 times.
✓ Branch 3 taken 2980 times.
✓ Branch 4 taken 6231 times.
✓ Branch 5 taken 6380 times.
15591 if(!inwallm && (action==none || action==walking))
1379 {
1380 9211 SetAttack();
1381 9211 attackclk=0;
1382 9211 attack=wCatching;
1383 9211 }
1384 15591 }
1385
1386 4421340 bool HeroClass::getClock()
1387 {
1388 4421340 return superman;
1389 }
1390 954 void HeroClass::setClock(bool state)
1391 {
1392 954 superman=state;
1393 954 }
1394 16731446 int32_t HeroClass::getFlashingCSet()
1395 {
1396 16731446 int32_t temp_cs = 6;
1397
2/2
✓ Branch 0 taken 16477067 times.
✓ Branch 1 taken 254379 times.
16731446 if (script_hero_cset > -1) temp_cs = script_hero_cset;
1398
2/2
✓ Branch 0 taken 2344627 times.
✓ Branch 1 taken 14386819 times.
16731446 if (!get_qr(qr_HEROFLICKER))
1399 {
1400
3/4
✓ Branch 0 taken 131470 times.
✓ Branch 1 taken 14255349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131470 times.
14386819 if (superman && getCanFlicker())
1401 {
1402 131470 temp_cs += (((~frame) >> 1) & 3);
1403 131470 }
1404
4/6
✓ Branch 0 taken 634214 times.
✓ Branch 1 taken 13621135 times.
✓ Branch 2 taken 634214 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 634214 times.
14255349 else if (hclk && (DivineProtectionShieldClk <= 0) && getCanFlicker())
1405 {
1406 634214 temp_cs += ((hclk >> 1) & 3);
1407 634214 }
1408 14386819 }
1409 16731446 return temp_cs;
1410 }
1411 17654430 bool HeroClass::is_hitflickerframe()
1412 {
1413
6/6
✓ Branch 0 taken 2496470 times.
✓ Branch 1 taken 15157960 times.
✓ Branch 2 taken 2433669 times.
✓ Branch 3 taken 62801 times.
✓ Branch 4 taken 107429 times.
✓ Branch 5 taken 2326240 times.
17654430 if (!(get_qr(qr_HEROFLICKER) && (superman || hclk)))
1414 17484200 return false;
1415
1416 170230 int32_t fr = game->get_spriteflickerspeed();
1417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170230 times.
170230 if (fr == 0)
1418 return true;
1419 170230 return frame % (fr * 2) >= fr;
1420 17654430 }
1421 109742994 int32_t HeroClass::getAction() // Used by ZScript
1422 {
1423
2/2
✓ Branch 0 taken 34580 times.
✓ Branch 1 taken 109708414 times.
109742994 if(spins > 0)
1424 34580 return isspinning;
1425
2/2
✓ Branch 0 taken 410457 times.
✓ Branch 1 taken 109297957 times.
109708414 else if(charging > 0)
1426 410457 return ischarging;
1427
2/2
✓ Branch 0 taken 109175287 times.
✓ Branch 1 taken 122670 times.
109297957 else if(diveclk > 0)
1428 122670 return isdiving;
1429 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1430
1431 109175287 return action;
1432 109742994 }
1433
1434 92677407 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1435 {
1436
2/2
✓ Branch 0 taken 25963 times.
✓ Branch 1 taken 92651444 times.
92677407 if(spins > 0)
1437 25963 return isspinning;
1438
2/2
✓ Branch 0 taken 333968 times.
✓ Branch 1 taken 92317476 times.
92651444 else if(charging > 0)
1439 333968 return ischarging;
1440
2/2
✓ Branch 0 taken 92118527 times.
✓ Branch 1 taken 198949 times.
92317476 else if(diveclk > 0)
1441 198949 return isdiving;
1442 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1443
1444 92118527 return -1;
1445 92677407 }
1446
1447 5206 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1448 {
1449
4/8
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5206 times.
10412 if(new_action==dying || new_action==won || new_action==scrolling ||
1450
3/6
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5206 times.
✗ Branch 5 not taken.
5206 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1451 5206 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1452 return; // Can't use these actions.
1453
1454
3/6
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4950 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5206 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1455 return;
1456
1457
1/2
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
5206 if(new_action==rafting)
1458 {
1459 if(get_qr(qr_DISALLOW_SETTING_RAFTING)) return;
1460 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1461 return;
1462 }
1463
1464
1465
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1466 {
1467 // Using Divine Escape
1468 if(magiccastclk<96)
1469 {
1470 // Not cast yet; cancel it
1471 magicitem=-1;
1472 magiccastclk=0;
1473 }
1474 else
1475 // Already activated; don't do anything
1476 return;
1477 }
1478
1479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
5206 if(action==inwind) // Remove from whirlwind
1480 {
1481 xofs=0;
1482 whirlwind=0;
1483 lstep=0;
1484 if ( dontdraw < 2 ) { dontdraw=0; }
1485 }
1486
2/4
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5206 times.
5206 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1487 {
1488 sprite* wind=0;
1489 bool foundWind=false;
1490 for(int32_t i=0; i<Ewpns.Count(); i++)
1491 {
1492 wind=Ewpns.spr(i);
1493 if(wind->id==ewWind && wind->misc==999)
1494 {
1495 foundWind=true;
1496 break;
1497 }
1498 }
1499
1500 if(foundWind)
1501 {
1502 xofs=0;
1503 if ( dontdraw < 2 ) { dontdraw=false; }
1504 wind->misc=-1;
1505 x=wind->x;
1506 y=wind->y;
1507 }
1508 }
1509
1510 //Unless compat rule is on, reset hopping clocks when writing action!
1511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(action == hopping && !get_qr(qr_NO_OVERWRITING_HOPPING))
1512 {
1513 hopclk = 0;
1514 hopdir = -1;
1515 }
1516
1517
3/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 2423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2783 times.
5206 if(new_action != attacking && new_action != sideswimattacking)
1518 {
1519 2783 attackclk=0;
1520
1521
1/2
✓ Branch 0 taken 2783 times.
✗ Branch 1 not taken.
2783 if(attack==wHookshot)
1522 reset_hookshot();
1523 2783 }
1524
2/4
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5206 times.
5206 if(new_action != isspinning && new_action != sideswimisspinning)
1525 {
1526 5206 charging = 0;
1527 5206 spins = 0;
1528 5206 }
1529
1530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(action == falling && new_action != falling)
1531 {
1532 fallclk = 0; //Stop falling;
1533 }
1534
1535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if (action == rafting && new_action != rafting)
1536 {
1537 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1538 raftwarpy = y;
1539 }
1540
1541
4/9
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2423 times.
✓ Branch 5 taken 2765 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5206 switch(new_action)
1542 {
1543 case isspinning:
1544 case sideswimisspinning:
1545 if(attack==wSword)
1546 {
1547 attackclk = SWORDCHARGEFRAME+1;
1548 charging = 0;
1549
1550 if(spins==0)
1551 spins = 5;
1552 }
1553 return;
1554
1555 case isdiving:
1556 if(action==swimming && diveclk==0)
1557 {
1558 int32_t flippers_id = current_item_id(itype_flippers);
1559 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1560 }
1561 return;
1562
1563 case drowning:
1564 case sidedrowning:
1565 clear_platform_ffc();
1566 if(!drownclk)
1567 Drown();
1568
1569 break;
1570
1571 case lavadrowning:
1572 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1573 clear_platform_ffc();
1574 if(!drownclk)
1575 Drown(1);
1576
1577 break;
1578
1579 case falling:
1580 clear_platform_ffc();
1581 if(!fallclk)
1582 {
1583 //If there is a pit under Hero, use its combo.
1584 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1585 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1586 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1587 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1588 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1589 //Else, use a null value; triggers default pit values
1590 else fallCombo = 0;
1591 fallclk = PITFALL_FALL_FRAMES;
1592 }
1593 break;
1594
1595 case gothit:
1596 case swimhit:
1597 case sideswimhit:
1598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!hclk)
1599 1 hclk=48;
1600 1 check_on_hit();
1601 1 break;
1602
1603 case landhold1:
1604 case landhold2:
1605 case waterhold1:
1606 case waterhold2:
1607 case sidewaterhold1:
1608 case sidewaterhold2:
1609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!holdclk)
1610 17 holdclk=130;
1611
1612 17 attack=none;
1613 17 break;
1614
1615 case attacking:
1616 case sideswimattacking:
1617 2423 attack=none;
1618 2423 break;
1619
1620 default:
1621 2765 break;
1622 }
1623
1624 5206 action=new_action; FFCore.setHeroAction(new_action);
1625 5206 }
1626
1627 48 void HeroClass::setHeldItem(int32_t newitem)
1628 {
1629 48 holditem=newitem;
1630 48 }
1631 204 int32_t HeroClass::getHeldItem()
1632 {
1633 204 return holditem;
1634 }
1635 20621595 bool HeroClass::isDiving()
1636 {
1637 20621595 int32_t flippers_id = current_item_id(itype_flippers);
1638
2/2
✓ Branch 0 taken 15177242 times.
✓ Branch 1 taken 5444353 times.
20621595 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1639 }
1640 45247740 bool HeroClass::isSwimming()
1641 {
1642 45247740 bool include_swimhit = true;
1643
3/4
✓ Branch 0 taken 45247740 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8798050 times.
✓ Branch 3 taken 36449690 times.
45247740 if (replay_is_active() && replay_version_check(0, 31))
1644 {
1645
2/4
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36449690 times.
36449690 std::string qst = replay_get_meta_str("qst");
1646 36449690 bool disable = false;
1647
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "demons_inferno.qst";
1648
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "demosp253.qst";
1649
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "hell_awaits.qst";
1650
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "lands_of_serenity.qst";
1651
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "link_to_the_heavens.qst";
1652 // The others are just a gfx change, but this one actual breaks without this compat check.
1653
1/2
✓ Branch 0 taken 36449690 times.
✗ Branch 1 not taken.
36449690 disable |= qst == "link_to_the_zelda.qst";
1654 36449690 include_swimhit = !disable;
1655 36449690 }
1656
4/6
✓ Branch 0 taken 44796536 times.
✓ Branch 1 taken 451204 times.
✓ Branch 2 taken 44796536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44796536 times.
✗ Branch 5 not taken.
90044276 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1657
8/8
✓ Branch 0 taken 44792523 times.
✓ Branch 1 taken 4013 times.
✓ Branch 2 taken 44789764 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 28309793 times.
✓ Branch 5 taken 16479971 times.
✓ Branch 6 taken 1166 times.
✓ Branch 7 taken 28308627 times.
44796536 (action==waterhold1)||(action==waterhold2)||(include_swimhit && action==swimhit)||
1658 44788598 (hopclk==0xFF));
1659 }
1660
1661 3422 void HeroClass::setDontDraw(byte new_dontdraw)
1662 {
1663 3422 dontdraw=new_dontdraw;
1664 3422 }
1665
1666 1981930 byte HeroClass::getDontDraw()
1667 {
1668 1981930 return dontdraw;
1669 }
1670
1671 3 void HeroClass::setHClk(int32_t newhclk)
1672 {
1673 3 hclk=newhclk;
1674 3 }
1675
1676 57322 int32_t HeroClass::getHClk()
1677 {
1678 57322 return hclk;
1679 }
1680
1681 11379027 int32_t HeroClass::getSpecialCave()
1682 {
1683 11379027 return specialcave; // used only by maps.cpp
1684 }
1685
1686 1559 void HeroClass::init()
1687 {
1688 1559 cache_tile_mod_clear();
1689 1559 usecounts.clear();
1690 1559 scale = 0;
1691 1559 rotation = 0;
1692 1559 do_animation = true;
1693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1559 times.
1559 if(lift_wpn)
1694 {
1695 delete lift_wpn;
1696 lift_wpn = nullptr;
1697 }
1698 1559 clear_platform_ffc();
1699 1559 liftclk = 0;
1700 1559 tliftclk = 0;
1701 1559 liftheight = 0;
1702 1559 liftflags = 0;
1703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1559 times.
1559 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1704 1559 hookshot_used=false;
1705 1559 justmoved = 0;
1706 1559 hookshot_frozen=false;
1707 1559 onpassivedmg=false;
1708 1559 dir = up;
1709 1559 damageovertimeclk = 0;
1710 1559 newconveyorclk = 0;
1711 1559 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1712
2/2
✓ Branch 0 taken 10913 times.
✓ Branch 1 taken 1559 times.
12472 for(auto q = 0; q < 7; ++q)
1713 10913 hooked_undercombos[q] = -1;
1714 1559 shiftdir = -1;
1715 1559 sideswimdir = right;
1716 1559 holddir = -1;
1717 1559 landswim = 0;
1718 1559 sdir = up;
1719 1559 ilswim=true;
1720 1559 walkable=false;
1721 1559 moveflags = move_obeys_grav | move_can_pitfall | move_can_waterdrown;
1722 1559 warp_sound = 0;
1723 1559 subscr_speed = zinit.subscrSpeed;
1724 1559 steprate = zinit.heroStep;
1725 1559 shove_offset = zinit.shove_offset;
1726 1559 is_warping = false;
1727 1559 coyotetime = 0;
1728
1729 1559 hammer_swim_up_offset = hammeroffsets[0];
1730 1559 hammer_swim_down_offset = hammeroffsets[1];
1731 1559 hammer_swim_left_offset = hammeroffsets[2];
1732 1559 hammer_swim_right_offset = hammeroffsets[3];
1733
1734 1559 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1735
1736
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 1143 times.
1559 if (hero_scr)
1737 {
1738
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 549 times.
1143 if(get_qr(qr_NOARRIVALPOINT))
1739 {
1740 594 x=hero_scr->warpreturnx[0];
1741 594 y=hero_scr->warpreturny[0];
1742 594 }
1743 else
1744 {
1745 549 x=hero_scr->warparrivalx;
1746 549 y=hero_scr->warparrivaly;
1747 }
1748 1143 }
1749
1750 1559 z=fakez=fall=fakefall=0;
1751 1559 hzsz = 12; // So that flying peahats can still hit him.
1752
1753
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 994 times.
1559 if(x==0) dir=right;
1754
1755
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1541 times.
1559 if(x==world_w-16) dir=left;
1756
1757
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 985 times.
1559 if(y==0) dir=down;
1758
1759
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 1258 times.
1559 if(y==world_h-16) dir=up;
1760
1761
2/2
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 416 times.
1559 if (hero_scr)
1762 {
1763 1143 x += region_scr_dx*256;
1764 1143 y += region_scr_dy*176;
1765 1143 update_viewport();
1766 1143 }
1767
1768 1559 lstep=0;
1769 1559 skipstep=0;
1770 1559 autostep=false;
1771 1559 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1772 1559 attack=wNone;
1773 1559 attackid=-1;
1774 1559 action=none; FFCore.setHeroAction(none); tempaction=none;
1775 1559 xofs=0;
1776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1559 times.
1559 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1777 1559 cs=6;
1778 1559 flickercolor=-1;
1779 1559 flickertransp=-1;
1780 1559 pushing=fairyclk=0;
1781 1559 id=0;
1782 1559 inlikelike=0;
1783 1559 superman=inwallm=false;
1784 1559 scriptcoldet=true;
1785 1559 blowcnt=whirlwind=specialcave=0;
1786 1559 hopclk=diveclk=fallclk=0;
1787 1559 fallCombo = 0;
1788 1559 pit_pulldir = -1;
1789 1559 hopdir=-1;
1790 1559 conveyor_flags=0;
1791 1559 drunkclk=0;
1792 1559 lstunclock = 0;
1793 1559 is_conveyor_stunned=0;
1794 1559 convey_forcex=convey_forcey=0;
1795 1559 drawstyle=3;
1796 1559 ffwarp = false;
1797 1559 stepoutindex=stepoutwr=stepoutdmap=stepoutscreen=0;
1798 1559 stepnext=stepsecret=rpos_t::None;
1799 1559 ffpit = false;
1800 1559 respawn_x=x;
1801 1559 respawn_y=y;
1802 1559 respawn_dmap=cur_dmap;
1803 1559 respawn_scr=cur_screen;
1804 1559 falling_oldy = y;
1805 1559 magiccastclk=0;
1806 1559 magicitem = div_prot_item = -1;
1807 1559 last_lens_id = 0; //Should be -1 (-Z)
1808 1559 last_lift_id.reset();
1809 1559 last_savepoint_id = 0;
1810 1559 misc_internal_hero_flags = 0;
1811 1559 last_cane_of_byrna_item_id = -1;
1812 1559 on_sideview_ladder = false;
1813 1559 standing_on_z = 0;
1814 1559 standing_z_offset = false;
1815 1559 extra_jump_count = 0;
1816 1559 hoverflags = 0;
1817 1559 lbunnyclock = 0;
1818 1559 lamp_paid = false;
1819
1820
2/2
✓ Branch 0 taken 49888 times.
✓ Branch 1 taken 1559 times.
51447 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1821
1822 1559 setBigHitbox(get_qr(qr_LTTPCOLLISION));
1823 1559 diagonalMovement=(get_qr(qr_LTTPWALK));
1824
1825 1559 shield_active = false;
1826 1559 shield_forcedir = -1;
1827 1559 active_shield_id = -1;
1828 1559 conv_forcedir = -1;
1829
1830 1559 preventsubscreenfalling = false; //-Z
1831 1559 walkspeed = 0; //not used, yet. -Z
1832
2/2
✓ Branch 0 taken 26503 times.
✓ Branch 1 taken 1559 times.
28062 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1833
2/2
✓ Branch 0 taken 26503 times.
✓ Branch 1 taken 1559 times.
28062 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1834
2/2
✓ Branch 0 taken 227614 times.
✓ Branch 1 taken 1559 times.
229173 for ( int32_t q = 0; q < wMax; q++ )
1835 {
1836 227614 defence[q] = hero_defenses[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1837 227614 }
1838
1839 1559 clear_ice();
1840 1559 script_ice_combo = 0;
1841 //Run script!
1842
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 152 times.
1559 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1843 {
1844 90 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_INIT);
1845 90 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_INIT);
1846 90 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1847 90 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1848 //are properly set by the engine.
1849 90 }
1850 1559 FFCore.nostepforward = 0;
1851
1852
2/2
✓ Branch 0 taken 6236 times.
✓ Branch 1 taken 1559 times.
7795 for (int i = 0; i < 4; i++)
1853 6236 lastdir[i] = 0xFF;
1854
1855
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 1237 times.
1559 if (replay_version_check(12))
1856 1237 z3step = 2;
1857 1559 }
1858
1859 16761324 void HeroClass::draw_under(BITMAP* dest)
1860 {
1861 16761324 int32_t c_raft=current_item_id(itype_raft);
1862 16761324 int32_t c_ladder=current_item_id(itype_ladder);
1863
1864
3/4
✓ Branch 0 taken 144426 times.
✓ Branch 1 taken 16616898 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144426 times.
16761324 if(action==rafting && c_raft >-1)
1865 {
1866
4/4
✓ Branch 0 taken 106833 times.
✓ Branch 1 taken 37593 times.
✓ Branch 2 taken 82762 times.
✓ Branch 3 taken 61664 times.
144426 if(((dir==left) || (dir==right)) && (get_qr(qr_RLFIX)))
1867 {
1868 123328 overtile16(dest, itemsbuf[c_raft].tile, x - viewport.x, y+playing_field_offset+4 - viewport.y,
1869 61664 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1870 61664 }
1871 else
1872 {
1873 165524 overtile16(dest, itemsbuf[c_raft].tile, x - viewport.x, y+playing_field_offset+4 - viewport.y,
1874 82762 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1875 }
1876 144426 }
1877
1878
3/4
✓ Branch 0 taken 142297 times.
✓ Branch 1 taken 16619027 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142297 times.
16761324 if(ladderx+laddery && c_ladder >-1)
1879 {
1880
4/4
✓ Branch 0 taken 67726 times.
✓ Branch 1 taken 74571 times.
✓ Branch 2 taken 44376 times.
✓ Branch 3 taken 23350 times.
142297 if((ladderdir>=left) && (get_qr(qr_RLFIX)))
1881 {
1882 88752 overtile16(dest, itemsbuf[c_ladder].tile, ladderx - viewport.x, laddery+playing_field_offset - viewport.y,
1883 44376 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[c_ladder].misc_flags>>2)&3)^3);
1884 44376 }
1885 else
1886 {
1887 195842 overtile16(dest, itemsbuf[c_ladder].tile, ladderx - viewport.x, laddery+playing_field_offset - viewport.y,
1888 97921 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1889 }
1890 142297 }
1891 16761324 }
1892
1893 19249 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1894 {
1895 19249 int32_t tempy=yofs;
1896 19249 yofs+=8;
1897 19249 shadowtile = wpnsbuf[spr_shadow].tile;
1898 19249 sprite::drawshadow(dest,translucent);
1899 19249 yofs=tempy;
1900 19249 }
1901
1902 // The Stone of Agony reacts to these flags.
1903 617536 bool HeroClass::agonyflag(int32_t flag)
1904 {
1905
1/2
✓ Branch 0 taken 617536 times.
✗ Branch 1 not taken.
617536 switch(flag)
1906 {
1907 case mfWHISTLE:
1908 case mfANYFIRE:
1909 case mfARROW:
1910 case mfBOMB:
1911 case mfSBOMB:
1912 case mfBRANG:
1913 case mfMBRANG:
1914 case mfFBRANG:
1915 case mfSARROW:
1916 case mfGARROW:
1917 case mfSTRONGFIRE:
1918 case mfMAGICFIRE:
1919 case mfDIVINEFIRE:
1920 case mfWANDMAGIC:
1921 case mfREFMAGIC:
1922 case mfREFFIREBALL:
1923 case mfSWORD:
1924 case mfWSWORD:
1925 case mfMSWORD:
1926 case mfXSWORD:
1927 case mfSWORDBEAM:
1928 case mfWSWORDBEAM:
1929 case mfMSWORDBEAM:
1930 case mfXSWORDBEAM:
1931 case mfHOOKSHOT:
1932 case mfWAND:
1933 case mfHAMMER:
1934 case mfSTRIKE:
1935 return true;
1936 }
1937
1938 617536 return false;
1939 617536 }
1940
1941
1942 // Find the attack power of the current melee weapon.
1943 // The Whimsical Ring is applied on a target-by-target basis.
1944 1110267 int32_t HeroClass::weaponattackpower(int32_t itid)
1945 {
1946
1/2
✓ Branch 0 taken 1110267 times.
✗ Branch 1 not taken.
1110267 if(itid < 0)
1947 {
1948 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1949 : attack==wWand ? itype_wand
1950 : attack==wHammer ? itype_hammer
1951 : itype_sword);
1952 }
1953
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1110247 times.
1110267 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1954
1955 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1956
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 1108078 times.
1110267 if(spins > 0)
1957 {
1958 2189 int screen = currentscroll;
1959
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 if(screen < 0)
1960 {
1961 screen = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1962 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1963 ? itype_spinscroll2 : itype_spinscroll);
1964 }
1965 2189 power *= itemsbuf[screen].power;
1966 2189 }
1967 1108078 else currentscroll = -1;
1968 1110267 return power;
1969 }
1970
1971 #define NET_CLK_TOTAL 24
1972 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1973 // Must only be called once per frame!
1974 138 void HeroClass::positionNet(weapon *w, int32_t itemid)
1975 {
1976 138 itemid = vbound(itemid, 0, MAXITEMS-1);
1977 138 int32_t t = w->o_tile,
1978 138 wx = 1, wy = 1;
1979
1980 //Invert positioning clock if right-handed animation
1981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 int32_t clock = (itemsbuf[itemid].flags&item_flag2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1982
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(clock >= NET_CLK_TOTAL)
1983 w->dead = 0;
1984 138 int32_t tiledir = dir;
1985
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 38 times.
138 switch(dir)
1986 {
1987 case up:
1988 {
1989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(clock < NET_DIR_INC) tiledir = l_up;
1990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1991 8 break;
1992 }
1993 case down:
1994 {
1995
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 48 times.
69 if(clock < NET_DIR_INC) tiledir = r_down;
1996
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1997 69 break;
1998 }
1999 case left:
2000 {
2001
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(clock < NET_DIR_INC) tiledir = l_down;
2002
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
2003 23 break;
2004 }
2005 case right:
2006 {
2007
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 if(clock < NET_DIR_INC) tiledir = r_up;
2008
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
2009 38 break;
2010 }
2011 }
2012 138 int32_t offs = 0;
2013
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 48 times.
138 if(tiledir > right)
2014 90 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
2015 48 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
2016 //One of 8 positions
2017
7/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 8 times.
138 switch(tiledir)
2018 {
2019 case up:
2020 {
2021 wx = 6*offs;
2022 wy = -14;
2023 break;
2024 }
2025 case r_up:
2026 {
2027 22 wx = (offs ? 10 : 14);
2028 22 wy = (offs ? -12 : -10);
2029 22 break;
2030 }
2031 case right:
2032 {
2033 16 wx = 14;
2034 16 wy = 6*offs;
2035 16 break;
2036 }
2037 case r_down:
2038 {
2039 29 wx = (offs ? 14 : 10);
2040 29 wy = (offs ? 10 : 12);
2041 29 break;
2042 }
2043 case down:
2044 {
2045 24 wx = -6*offs;
2046 24 wy = 14;
2047 24 break;
2048 }
2049 case l_down:
2050 {
2051 31 wx = (offs ? -10 : -14);
2052 31 wy = (offs ? 12 : 10);
2053 31 break;
2054 }
2055 case left:
2056 {
2057 8 wx = -14;
2058 8 wy = -6*offs;
2059 8 break;
2060 }
2061 case l_up:
2062 {
2063 8 wx = (offs ? -14 : -10);
2064 8 wy = (offs ? -10 : -12);
2065 8 break;
2066 }
2067 }
2068
2069 138 w->x = x+wx;
2070 138 w->y = y+wy-(original_playing_field_offset-2-yofs)-fakez;
2071 138 w->z = (z+zofs);
2072 138 w->fakez = fakez;
2073 138 w->tile = t+tiledir;
2074 138 w->power = 0;
2075 138 w->dir = dir;
2076 138 w->doAutoRotate(true);
2077 138 }
2078 970888 void HeroClass::positionSword(weapon *w, int32_t itemid)
2079 {
2080 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
2081 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2082 970888 itemid=vbound(itemid, 0, MAXITEMS-1);
2083 // Place a sword weapon at the right spot.
2084 970888 int32_t wy=1;
2085 970888 int32_t wx=1;
2086 970888 int32_t f=0,t,cs2;
2087
2088 970888 t = w->o_tile;
2089 970888 cs2 = w->o_cset;
2090 970888 slashxofs=0;
2091 970888 slashyofs=0;
2092
2093
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 198027 times.
✓ Branch 2 taken 209123 times.
✓ Branch 3 taken 280583 times.
✓ Branch 4 taken 283155 times.
970888 switch(dir)
2094 {
2095 case up:
2096 198027 wx=-1;
2097 198027 wy=-12;
2098
2099
8/8
✓ Branch 0 taken 88861 times.
✓ Branch 1 taken 109166 times.
✓ Branch 2 taken 87284 times.
✓ Branch 3 taken 1577 times.
✓ Branch 4 taken 86729 times.
✓ Branch 5 taken 555 times.
✓ Branch 6 taken 8142 times.
✓ Branch 7 taken 78587 times.
198027 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2100 {
2101
2/2
✓ Branch 0 taken 50379 times.
✓ Branch 1 taken 28208 times.
78587 if(attackclk>10) //extended stab
2102 {
2103 28208 slashyofs-=3;
2104 28208 wy-=2;
2105 28208 }
2106
2107
2/2
✓ Branch 0 taken 70149 times.
✓ Branch 1 taken 8438 times.
78587 if(attackclk>=14) //retracting stab
2108 {
2109 8438 slashyofs+=3;
2110 8438 wy+=2;
2111 8438 }
2112 78587 }
2113 else
2114 {
2115
2/2
✓ Branch 0 taken 6746 times.
✓ Branch 1 taken 112694 times.
119440 if(attackclk==SWORDCHARGEFRAME)
2116 {
2117 6746 wy+=4;
2118 6746 }
2119
2/2
✓ Branch 0 taken 10921 times.
✓ Branch 1 taken 101773 times.
112694 else if(attackclk==13)
2120 {
2121 10921 wy+=4;
2122 10921 }
2123
2/2
✓ Branch 0 taken 90960 times.
✓ Branch 1 taken 10813 times.
101773 else if(attackclk==14)
2124 {
2125 10813 wy+=8;
2126 10813 }
2127 }
2128
2129 198027 break;
2130
2131 case down:
2132 209123 f=get_qr(qr_SWORDWANDFLIPFIX)?3:2;
2133 209123 wy=11;
2134
2135
8/8
✓ Branch 0 taken 112256 times.
✓ Branch 1 taken 96867 times.
✓ Branch 2 taken 110853 times.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 110141 times.
✓ Branch 5 taken 712 times.
✓ Branch 6 taken 6988 times.
✓ Branch 7 taken 103153 times.
209123 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2136 {
2137
2/2
✓ Branch 0 taken 64900 times.
✓ Branch 1 taken 38253 times.
103153 if(attackclk>10) //extended stab
2138 {
2139 38253 slashyofs+=3;
2140 38253 wy+=2;
2141 38253 }
2142
2143
2/2
✓ Branch 0 taken 91566 times.
✓ Branch 1 taken 11587 times.
103153 if(attackclk>=14) //retracting stab
2144 {
2145 11587 slashyofs-=3;
2146 11587 wy-=2;
2147 11587 }
2148 103153 }
2149 else
2150 {
2151
2/2
✓ Branch 0 taken 6473 times.
✓ Branch 1 taken 99497 times.
105970 if(attackclk==SWORDCHARGEFRAME)
2152 {
2153 6473 wy-=2;
2154 6473 }
2155
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 89595 times.
99497 else if(attackclk==13)
2156 {
2157 9902 wy-=4;
2158 9902 }
2159
2/2
✓ Branch 0 taken 79728 times.
✓ Branch 1 taken 9867 times.
89595 else if(attackclk==14)
2160 {
2161 9867 wy-=8;
2162 9867 }
2163 }
2164
2165 209123 break;
2166
2167 case left:
2168 280583 f=1;
2169 280583 wx=-11;
2170 280583 ++t;
2171
2172
8/8
✓ Branch 0 taken 159182 times.
✓ Branch 1 taken 121401 times.
✓ Branch 2 taken 155483 times.
✓ Branch 3 taken 3699 times.
✓ Branch 4 taken 154036 times.
✓ Branch 5 taken 1447 times.
✓ Branch 6 taken 10065 times.
✓ Branch 7 taken 143971 times.
280583 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2173 {
2174
2/2
✓ Branch 0 taken 89622 times.
✓ Branch 1 taken 54349 times.
143971 if(attackclk>10) //extended stab
2175 {
2176 54349 slashxofs-=4;
2177 54349 wx-=7;
2178 54349 }
2179
2180
2/2
✓ Branch 0 taken 128009 times.
✓ Branch 1 taken 15962 times.
143971 if(attackclk>=14) //retracting stab
2181 {
2182 15962 slashxofs+=3;
2183 15962 wx+=7;
2184 15962 }
2185 143971 }
2186 else
2187 {
2188
2/2
✓ Branch 0 taken 8752 times.
✓ Branch 1 taken 127860 times.
136612 if(attackclk==SWORDCHARGEFRAME)
2189 {
2190 8752 wx+=2;
2191 8752 }
2192
2/2
✓ Branch 0 taken 12715 times.
✓ Branch 1 taken 115145 times.
127860 else if(attackclk==13)
2193 {
2194 12715 wx+=4;
2195 12715 }
2196
2/2
✓ Branch 0 taken 102473 times.
✓ Branch 1 taken 12672 times.
115145 else if(attackclk==14)
2197 {
2198 12672 wx+=8;
2199 12672 }
2200 }
2201
2202 280583 break;
2203
2204 case right:
2205 283155 wx=11;
2206 283155 ++t;
2207
2208
8/8
✓ Branch 0 taken 155482 times.
✓ Branch 1 taken 127673 times.
✓ Branch 2 taken 152680 times.
✓ Branch 3 taken 2802 times.
✓ Branch 4 taken 149384 times.
✓ Branch 5 taken 3296 times.
✓ Branch 6 taken 13666 times.
✓ Branch 7 taken 135718 times.
283155 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2209 {
2210
2/2
✓ Branch 0 taken 84139 times.
✓ Branch 1 taken 51579 times.
135718 if(attackclk>10) //extended stab
2211 {
2212 51579 slashxofs+=4;
2213 51579 wx+=7;
2214 51579 }
2215
2216
2/2
✓ Branch 0 taken 120013 times.
✓ Branch 1 taken 15705 times.
135718 if(attackclk>=14) //retracting stab
2217 {
2218 15705 slashxofs-=3;
2219 15705 wx-=7;
2220 15705 }
2221 135718 }
2222 else
2223 {
2224
2/2
✓ Branch 0 taken 12322 times.
✓ Branch 1 taken 135115 times.
147437 if(attackclk==SWORDCHARGEFRAME)
2225 {
2226 12322 wx-=2;
2227 12322 }
2228
2/2
✓ Branch 0 taken 13394 times.
✓ Branch 1 taken 121721 times.
135115 else if(attackclk==13)
2229 {
2230 13394 wx-=4;
2231 13394 }
2232
2/2
✓ Branch 0 taken 108365 times.
✓ Branch 1 taken 13356 times.
121721 else if(attackclk==14)
2233 {
2234 13356 wx-=8;
2235 13356 }
2236 }
2237
2238 283155 break;
2239 }
2240
2241
6/6
✓ Branch 0 taken 515781 times.
✓ Branch 1 taken 455107 times.
✓ Branch 2 taken 503076 times.
✓ Branch 3 taken 12705 times.
✓ Branch 4 taken 212239 times.
✓ Branch 5 taken 290837 times.
970888 if(game->get_canslash() && itemsbuf[itemid].flags & item_flag4 && attackclk<11)
2242 {
2243 290837 int32_t wpn2=itemsbuf[itemid].wpn2;
2244 290837 wpn2=vbound(wpn2, 0, MAXWPNS);
2245
2246 //slashing tiles
2247
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 50664 times.
✓ Branch 2 taken 65294 times.
✓ Branch 3 taken 90255 times.
✓ Branch 4 taken 84624 times.
290837 switch(dir)
2248 {
2249 case up:
2250 50664 wx=15;
2251 50664 wy=-3;
2252 50664 ++t;
2253 50664 f=0; //starts pointing right
2254
2255
2/2
✓ Branch 0 taken 22596 times.
✓ Branch 1 taken 28068 times.
50664 if(attackclk>=7)
2256 {
2257 28068 wy-=9;
2258 28068 wx-=3;
2259 28068 t = wpnsbuf[wpn2].tile;
2260 28068 cs2 = wpnsbuf[wpn2].csets&15;
2261 28068 f=0;
2262 28068 }
2263
2264 50664 break;
2265
2266 case down:
2267 65294 wx=-13;
2268 65294 wy=-1;
2269 65294 ++t;
2270 65294 f=1; //starts pointing left
2271
2272
2/2
✓ Branch 0 taken 28500 times.
✓ Branch 1 taken 36794 times.
65294 if(attackclk>=7)
2273 {
2274 36794 wy+=15;
2275 36794 wx+=2;
2276 36794 t = wpnsbuf[wpn2].tile;
2277 36794 cs2 = wpnsbuf[wpn2].csets&15;
2278 36794 ++t;
2279 36794 f=0;
2280 36794 }
2281
2282 65294 break;
2283
2284 case left:
2285 90255 wx=3;
2286 90255 wy=-15;
2287 90255 --t;
2288 90255 f=0; //starts pointing up
2289
2290
2/2
✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 51771 times.
90255 if(attackclk>=7)
2291 {
2292 51771 wx-=15;
2293 51771 wy+=3;
2294 51771 slashxofs-=1;
2295 51771 t = wpnsbuf[wpn2].tile;
2296 51771 cs2 = wpnsbuf[wpn2].csets&15;
2297 51771 t+=2;
2298 51771 f=0;
2299 51771 }
2300
2301 90255 break;
2302
2303 case right:
2304 84624 --t;
2305
2306
3/4
✓ Branch 0 taken 84211 times.
✓ Branch 1 taken 413 times.
✓ Branch 2 taken 84211 times.
✗ Branch 3 not taken.
84624 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2307 {
2308 413 wx=1;
2309 413 wy=13;
2310 413 f=2;
2311 413 }
2312 else
2313 {
2314 84211 wx=3;
2315 84211 wy=-15;
2316 84211 f=0;
2317 }
2318
2319
2/2
✓ Branch 0 taken 36128 times.
✓ Branch 1 taken 48496 times.
84624 if(attackclk>=7)
2320 {
2321 48496 wx+=15;
2322 48496 slashxofs+=1;
2323 48496 t = wpnsbuf[wpn2].tile;
2324 48496 cs2 = wpnsbuf[wpn2].csets&15;
2325
2326
3/4
✓ Branch 0 taken 48221 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 48221 times.
✗ Branch 3 not taken.
48496 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2327 {
2328 275 wx-=1;
2329 275 wy-=2;
2330 275 }
2331 else
2332 {
2333 48221 t+=3;
2334 48221 f=0;
2335 48221 wy+=3;
2336 }
2337 48496 }
2338
2339 84624 break;
2340 }
2341 290837 }
2342
2343 970888 int32_t itemid2 = current_item_id(itype_chargering);
2344
2345
4/4
✓ Branch 0 taken 28541 times.
✓ Branch 1 taken 942347 times.
✓ Branch 2 taken 957767 times.
✓ Branch 3 taken 13121 times.
970888 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2346 {
2347
2/2
✓ Branch 0 taken 12589 times.
✓ Branch 1 taken 532 times.
13121 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2348 13121 }
2349
2350 970888 w->x = x+wx;
2351 970888 w->y = y+wy-(original_playing_field_offset-2-(yofs+slashyofs))-fakez;
2352 970888 w->z = (z+zofs);
2353 970888 w->tile = t;
2354 970888 w->flip = f;
2355 970888 w->power = weaponattackpower(itemid);
2356 970888 w->dir = dir;
2357 970888 w->doAutoRotate(true);
2358 970888 }
2359
2360 int HeroClass::getHammerState() const
2361 {
2362 if(attack == wHammer)
2363 {
2364 if(attackclk >= 15)
2365 return 3;
2366 if(attackclk >= 13)
2367 return 2;
2368 return 1;
2369 }
2370 return 0;
2371 }
2372 1101524 weapon* find_first_wtype(int wtype)
2373 {
2374
2/2
✓ Branch 0 taken 1184951 times.
✓ Branch 1 taken 89358 times.
1274309 for(int32_t i=0; i<Lwpns.Count(); i++)
2375 {
2376 1184951 weapon* w = (weapon*)Lwpns.spr(i);
2377
2378
2/2
✓ Branch 0 taken 1012166 times.
✓ Branch 1 taken 172785 times.
1184951 if(w->id == wtype)
2379 1012166 return w;
2380 172785 }
2381 89358 return nullptr;
2382 1101524 }
2383 16890863 void HeroClass::draw(BITMAP* dest)
2384 {
2385 16890863 int32_t oxofs = xofs, oyofs = yofs;
2386
2/2
✓ Branch 0 taken 94966 times.
✓ Branch 1 taken 16795897 times.
16890863 bool invisible=(dontdraw>0) || (hero_scr->flags3&fINVISHERO);
2387
2388 {
2389
2/2
✓ Branch 0 taken 16957 times.
✓ Branch 1 taken 16873906 times.
16890863 if(action==dying)
2390 {
2391
2/2
✓ Branch 0 taken 12844 times.
✓ Branch 1 taken 4113 times.
16957 if(!invisible)
2392 {
2393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4113 times.
4113 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2394 4113 sprite::draw(dest);
2395 4113 }
2396 16957 goto herodraw_end;
2397 }
2398
2399 16873906 bool useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2400
2401
2402
2/2
✓ Branch 0 taken 278645 times.
✓ Branch 1 taken 16595261 times.
16873906 if(!invisible)
2403
6/6
✓ Branch 0 taken 7414946 times.
✓ Branch 1 taken 9180315 times.
✓ Branch 2 taken 4809023 times.
✓ Branch 3 taken 2605923 times.
✓ Branch 4 taken 183822 times.
✓ Branch 5 taken 4625201 times.
16595261 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2404
2405 // Stone of Agony
2406 16873906 bool agony=false;
2407 16873906 int32_t agonyid = current_item_id(itype_agony);
2408
2409
2/2
✓ Branch 0 taken 278645 times.
✓ Branch 1 taken 16595261 times.
16873906 if(!invisible)
2410 {
2411
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 16286493 times.
16595261 if(agonyid>-1)
2412 {
2413 308768 int32_t power=itemsbuf[agonyid].power;
2414 308768 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2415 308768 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2416 308768 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2417 308768 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2418
2419
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 308768 times.
617536 for(int32_t x=left; x<right; x+=16)
2420 {
2421
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 308768 times.
617536 for(int32_t y=top; y<bottom; y+=16)
2422 {
2423
2/4
✓ Branch 0 taken 308768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 308768 times.
✗ Branch 3 not taken.
308768 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2424 {
2425 agony=true;
2426 x=right; // Break out of outer loop
2427 break;
2428 }
2429 308768 }
2430 308768 }
2431 308768 }
2432
2433 16595261 cs = getFlashingCSet();
2434 16595261 }
2435
2436
5/6
✓ Branch 0 taken 15133354 times.
✓ Branch 1 taken 1740552 times.
✓ Branch 2 taken 15120085 times.
✓ Branch 3 taken 13269 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15120085 times.
16873906 if(attackclk || (action==attacking||action==sideswimattacking))
2437 {
2438 /* Spaghetti code constants!
2439 * - Hero.attack contains a weapon type...
2440 * - which must be converted to an itype...
2441 * - which must be converted to an item ID...
2442 * - which is used to acquire a wpn ID! Aack!
2443 */
2444
8/8
✓ Branch 0 taken 38963 times.
✓ Branch 1 taken 1714858 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 1714830 times.
✓ Branch 4 taken 25729 times.
✓ Branch 5 taken 1689101 times.
✓ Branch 6 taken 64669 times.
✓ Branch 7 taken 1624432 times.
1753821 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2445
4/4
✓ Branch 0 taken 493821 times.
✓ Branch 1 taken 1199064 times.
✓ Branch 2 taken 324952 times.
✓ Branch 3 taken 168869 times.
1753821 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2446 1692885 itemid=vbound(itemid, 0, MAXITEMS-1);
2447 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2448
8/8
✓ Branch 0 taken 577194 times.
✓ Branch 1 taken 1115691 times.
✓ Branch 2 taken 577170 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 380383 times.
✓ Branch 5 taken 196787 times.
✓ Branch 6 taken 215914 times.
✓ Branch 7 taken 164469 times.
1692885 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2449 {
2450
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1331491 times.
1331629 if(attack == wBugNet)
2451 {
2452 138 weapon *w=NULL;
2453 138 bool found = false;
2454
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 132 times.
138 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2455 {
2456 132 w = (weapon*)Lwpns.spr(q);
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(w->id == wBugNet)
2458 {
2459 132 found = true;
2460 132 break;
2461 }
2462 }
2463
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6 times.
138 if(!found)
2464 {
2465 // TODO(crash): check that .add succeeds.
2466
5/10
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
6 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2467
2468 6 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2469 6 }
2470 138 positionNet(w, itemid);
2471 138 }
2472
8/8
✓ Branch 0 taken 248832 times.
✓ Branch 1 taken 1082659 times.
✓ Branch 2 taken 230458 times.
✓ Branch 3 taken 18374 times.
✓ Branch 4 taken 215664 times.
✓ Branch 5 taken 14794 times.
✓ Branch 6 taken 229968 times.
✓ Branch 7 taken 1101523 times.
1331491 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2473 {
2474 // Create a sword weapon at the right spot.
2475 1101523 weapon *w=find_first_wtype(attack==wSword ? wSword : wWand);
2476
2/2
✓ Branch 0 taken 1012165 times.
✓ Branch 1 taken 89358 times.
1101523 if(!w) // Create one if sword nonexistant
2477 {
2478
5/10
✓ Branch 0 taken 89358 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89358 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89358 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89358 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 89358 times.
✗ Branch 9 not taken.
89358 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2479 89358 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2480
2481 89358 positionSword(w,itemid);
2482
2483 // Stone of Agony
2484
1/2
✓ Branch 0 taken 89358 times.
✗ Branch 1 not taken.
89358 if(agony)
2485 {
2486 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2487 }
2488 89358 }
2489
2490 // These are set by positionSword(), above or in checkstab()
2491 1101523 yofs += slashyofs;
2492 1101523 xofs += slashxofs;
2493 1101523 slashyofs = slashxofs = 0;
2494 1101523 }
2495 1331629 }
2496
2497 1692987 if(attackclk<7
2498
4/4
✓ Branch 0 taken 921785 times.
✓ Branch 1 taken 771100 times.
✓ Branch 2 taken 735714 times.
✓ Branch 3 taken 186071 times.
1692885 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2499
4/6
✓ Branch 0 taken 137324 times.
✓ Branch 1 taken 598390 times.
✓ Branch 2 taken 137324 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 137324 times.
735714 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2500
2/2
✓ Branch 0 taken 38044 times.
✓ Branch 1 taken 99280 times.
137324 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2501
4/4
✓ Branch 0 taken 304556 times.
✓ Branch 1 taken 24229 times.
✓ Branch 2 taken 293092 times.
✓ Branch 3 taken 11464 times.
323395 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2502
4/4
✓ Branch 0 taken 29461 times.
✓ Branch 1 taken 299324 times.
✓ Branch 2 taken 50971 times.
✓ Branch 3 taken 248353 times.
328785 || (attack==wHammer && attackclk<=30)
2503
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 248251 times.
299324 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2504 {
2505
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 1487728 times.
1488068 if(!invisible)
2506 {
2507 1487728 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2508
2/4
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487728 times.
✗ Branch 3 not taken.
1487728 if (FIXED_Z3_ANIMATION)
2509 {
2510 if (attackclk >= 2) tile += (extend==2?2:1);
2511 if (attackclk >= 13) tile += (extend==2?2:1);
2512 }
2513
2514
14/18
✓ Branch 0 taken 750280 times.
✓ Branch 1 taken 737448 times.
✓ Branch 2 taken 157640 times.
✓ Branch 3 taken 592640 times.
✓ Branch 4 taken 146759 times.
✓ Branch 5 taken 10881 times.
✓ Branch 6 taken 142255 times.
✓ Branch 7 taken 4504 times.
✓ Branch 8 taken 588309 times.
✓ Branch 9 taken 161971 times.
✓ Branch 10 taken 333492 times.
✓ Branch 11 taken 254817 times.
✓ Branch 12 taken 333492 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 333492 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
1487728 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&item_flag4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2515 {
2516 254817 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2517
2/4
✓ Branch 0 taken 254817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 254817 times.
✗ Branch 3 not taken.
254817 if (FIXED_Z3_ANIMATION)
2518 {
2519 if (attackclk >= 7) tile += (extend==2?2:1);
2520 if (attackclk >= 11) tile += (extend==2?2:1);
2521 if (attackclk >= 14) tile += (extend==2?2:1);
2522 }
2523 254817 }
2524
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1487590 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
1487728 if (attack==wBugNet && !get_qr(qr_OLD_BUG_NET))
2525 {
2526
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 62 times.
138 if ((dir == right && (itemsbuf[itemid].flags&item_flag2)) || (dir != right && !(itemsbuf[itemid].flags&item_flag2)))
2527 {
2528
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 32 times.
100 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2529
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 40 times.
100 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2530 100 }
2531 else
2532 {
2533
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
162 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2534
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8 times.
38 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2535 }
2536 138 }
2537
2538
4/4
✓ Branch 0 taken 64669 times.
✓ Branch 1 taken 1423059 times.
✓ Branch 2 taken 37763 times.
✓ Branch 3 taken 26906 times.
1487728 if((attack==wHammer) && (attackclk<13))
2539 {
2540 26906 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2541
2/4
✓ Branch 0 taken 26906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26906 times.
✗ Branch 3 not taken.
26906 if (FIXED_Z3_ANIMATION)
2542 {
2543 if (attackclk >= 14) tile += (extend==2?2:1);
2544 if (attackclk >= 16) tile += (extend==2?2:1);
2545 }
2546 26906 }
2547
2548
2/2
✓ Branch 0 taken 987175 times.
✓ Branch 1 taken 500553 times.
1487728 if(useltm)
2549 {
2550
2/2
✓ Branch 0 taken 1885 times.
✓ Branch 1 taken 498668 times.
500553 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2551 500553 }
2552
2553 // Stone of Agony
2554
1/2
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
1487728 if(agony)
2555 {
2556 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2557 }
2558
2559 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2560
2561 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2562
2/2
✓ Branch 0 taken 12487 times.
✓ Branch 1 taken 1475241 times.
1487728 if (is_hitflickerframe())
2563 {
2564
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12485 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12485 times.
12487 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
2565
2/4
✓ Branch 0 taken 12487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12487 times.
✗ Branch 3 not taken.
12487 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
2566 {
2567 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
2568 sprite_flicker_color = temp_flicker_color;
2569 masked_draw(dest);
2570 }
2571 12487 }
2572 else
2573 1475241 masked_draw(dest);
2574
2575 //Prevent flickering -Z
2576
1/2
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
1487728 if (!getCanFlicker()) masked_draw(dest);
2577 1487728 }
2578
2579
2/2
✓ Branch 0 taken 1423399 times.
✓ Branch 1 taken 64669 times.
1488068 if(attack!=wHammer)
2580 1423399 goto herodraw_end;
2581 64669 }
2582
2583
2/2
✓ Branch 0 taken 64669 times.
✓ Branch 1 taken 248251 times.
312920 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2584 {
2585 64669 int32_t wy=1;
2586 64669 int32_t wx=1;
2587 64669 int32_t f=0,t,cs2;
2588 64669 weapon *w=NULL;
2589 64669 bool found = false;
2590
2591
2/2
✓ Branch 0 taken 2257 times.
✓ Branch 1 taken 63298 times.
65555 for(int32_t i=0; i<Lwpns.Count(); i++)
2592 {
2593 63298 w = (weapon*)Lwpns.spr(i);
2594
2595
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 62412 times.
63298 if(w->id == wHammer)
2596 {
2597 62412 found = true;
2598 62412 break;
2599 }
2600 886 }
2601
2602
2/2
✓ Branch 0 taken 62412 times.
✓ Branch 1 taken 2257 times.
64669 if(!found)
2603 {
2604
5/10
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2257 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2257 times.
✗ Branch 9 not taken.
2257 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2605 2257 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2606 2257 found = true;
2607 2257 }
2608
2609 64669 t = w->o_tile;
2610 64669 cs2 = w->o_cset;
2611
2612
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10368 times.
✓ Branch 2 taken 15134 times.
✓ Branch 3 taken 21186 times.
✓ Branch 4 taken 17981 times.
64669 switch(dir)
2613 {
2614 case up:
2615 10368 wx=-1;
2616 10368 wy=-15;
2617
1/2
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
10368 if (IsSideSwim())wy+=hammer_swim_up_offset;
2618
2619
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 5985 times.
10368 if(attackclk>=13)
2620 {
2621 5985 wx-=1;
2622 5985 wy+=1;
2623 5985 ++t;
2624 5985 }
2625
2626
2/2
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 5307 times.
10368 if(attackclk>=15)
2627 {
2628
1/2
✓ Branch 0 taken 5307 times.
✗ Branch 1 not taken.
5307 if (IsSideSwim())wy-=hammer_swim_up_offset;
2629 5307 ++t;
2630 5307 }
2631
2632 10368 break;
2633
2634 case down:
2635 15134 wx=3;
2636 15134 wy=-14;
2637
1/2
✓ Branch 0 taken 15134 times.
✗ Branch 1 not taken.
15134 if (IsSideSwim())wy+=hammer_swim_down_offset;
2638 15134 t+=3;
2639
2640
2/2
✓ Branch 0 taken 6339 times.
✓ Branch 1 taken 8795 times.
15134 if(attackclk>=13)
2641 {
2642 8795 wy+=16;
2643 8795 ++t;
2644 8795 }
2645
2646
2/2
✓ Branch 0 taken 7346 times.
✓ Branch 1 taken 7788 times.
15134 if(attackclk>=15)
2647 {
2648 7788 wx-=1;
2649 7788 wy+=12;
2650
1/2
✓ Branch 0 taken 7788 times.
✗ Branch 1 not taken.
7788 if (IsSideSwim())wy-=hammer_swim_down_offset;
2651 7788 ++t;
2652 7788 }
2653
2654 15134 break;
2655
2656 case left:
2657 21186 wx=0;
2658 21186 wy=-14;
2659
1/2
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
21186 if (IsSideSwim())wy+=hammer_swim_left_offset;
2660 21186 t+=6;
2661 21186 f=1;
2662
2663
2/2
✓ Branch 0 taken 8801 times.
✓ Branch 1 taken 12385 times.
21186 if(attackclk>=13)
2664 {
2665 12385 wx-=7;
2666 12385 wy+=8;
2667 12385 ++t;
2668 12385 }
2669
2670
2/2
✓ Branch 0 taken 10219 times.
✓ Branch 1 taken 10967 times.
21186 if(attackclk>=15)
2671 {
2672 10967 wx-=8;
2673 10967 wy+=8;
2674
1/2
✓ Branch 0 taken 10967 times.
✗ Branch 1 not taken.
10967 if (IsSideSwim())wy-=hammer_swim_left_offset;
2675 10967 ++t;
2676 10967 }
2677
2678 21186 break;
2679
2680 case right:
2681 17981 wx=0;
2682 17981 wy=-14;
2683
1/2
✓ Branch 0 taken 17981 times.
✗ Branch 1 not taken.
17981 if (IsSideSwim())wy+=hammer_swim_right_offset;
2684 17981 t+=6;
2685
2686
2/2
✓ Branch 0 taken 7383 times.
✓ Branch 1 taken 10598 times.
17981 if(attackclk>=13)
2687 {
2688 10598 wx+=7;
2689 10598 wy+=8;
2690 10598 ++t;
2691 10598 }
2692
2693
2/2
✓ Branch 0 taken 8581 times.
✓ Branch 1 taken 9400 times.
17981 if(attackclk>=15)
2694 {
2695 9400 wx+=8;
2696 9400 wy+=8;
2697
1/2
✓ Branch 0 taken 9400 times.
✗ Branch 1 not taken.
9400 if (IsSideSwim())wy-=hammer_swim_right_offset;
2698 9400 ++t;
2699 9400 }
2700
2701 17981 break;
2702 }
2703
2704
7/8
✓ Branch 0 taken 28062 times.
✓ Branch 1 taken 36607 times.
✓ Branch 2 taken 20878 times.
✓ Branch 3 taken 7184 times.
✓ Branch 4 taken 20878 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4720 times.
✓ Branch 7 taken 16158 times.
64669 if(BSZ || ((isdungeon() && cur_screen<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2705 {
2706 52765 wy+=2;
2707 52765 }
2708
2709 // Stone of Agony
2710
1/2
✓ Branch 0 taken 64669 times.
✗ Branch 1 not taken.
64669 if(agony)
2711 {
2712 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2713 }
2714
2715 64669 w->x = x+wx;
2716 64669 w->y = y+wy-(original_playing_field_offset-2-yofs)-fakez;
2717 64669 w->z = (z+zofs);
2718 64669 w->tile = t;
2719 64669 w->flip = f;
2720 64669 w->hit_width=20;
2721 64669 w->hit_height=20;
2722
2723
2/2
✓ Branch 0 taken 39167 times.
✓ Branch 1 taken 25502 times.
64669 if(dir>down)
2724 {
2725 39167 w->hit_height-=6;
2726 39167 }
2727 else
2728 {
2729 25502 w->hit_width-=6;
2730 25502 w->hyofs=4;
2731 }
2732
2733 64669 w->power = weaponattackpower(itemid);
2734
2735
7/10
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 62537 times.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2132 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2127 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
64669 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2736 {
2737
3/4
✓ Branch 0 taken 2120 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 sfx(((iswaterex_z3(MAPCOMBO(x+wx+8,y+wy), -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_qr(qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2738 2132 }
2739
2740 64669 goto herodraw_end;
2741 }
2742 248251 }
2743
2/4
✓ Branch 0 taken 15120085 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15120085 times.
15120085 else if(!charging && !spins) // remove the sword
2744 {
2745
2/2
✓ Branch 0 taken 2967273 times.
✓ Branch 1 taken 15120085 times.
18087358 for(int32_t i=0; i<Lwpns.Count(); i++)
2746 {
2747 2967273 weapon *w = (weapon*)Lwpns.spr(i);
2748
2749
6/6
✓ Branch 0 taken 2966376 times.
✓ Branch 1 taken 897 times.
✓ Branch 2 taken 2964868 times.
✓ Branch 3 taken 1508 times.
✓ Branch 4 taken 31846 times.
✓ Branch 5 taken 2933022 times.
2967273 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2750 34251 w->dead=1;
2751 2967273 }
2752 15120085 }
2753
2754
2/2
✓ Branch 0 taken 260803 times.
✓ Branch 1 taken 15107533 times.
15368336 if(invisible)
2755 {
2756 260803 goto herodraw_end;
2757 }
2758
2759
3/4
✓ Branch 0 taken 15104686 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15104686 times.
15107533 if(action != casting && action != sideswimcasting)
2760 {
2761 // Keep this consistent with checkspecial2, line 7800-ish...
2762
6/6
✓ Branch 0 taken 295622 times.
✓ Branch 1 taken 14809064 times.
✓ Branch 2 taken 285645 times.
✓ Branch 3 taken 9977 times.
✓ Branch 4 taken 10634 times.
✓ Branch 5 taken 275011 times.
15104686 bool inwater = iswaterex_z3(MAPCOMBO(x+4,y+9), -1, x+4, y+9, true, false) && iswaterex_z3(MAPCOMBO(x+4,y+15), -1, x+4, y+15, true, false) && iswaterex_z3(MAPCOMBO(x+11,y+9), -1, x+11, y+9, true, false) && iswaterex_z3(MAPCOMBO(x+11,y+15), -1, x+11, y+15, true, false);
2763
2764 15104686 int32_t jumping2 = int32_t(jumping*((zinit.gravity / 100)/16.0));
2765 15104686 bool noliftspr = get_qr(qr_NO_LIFT_SPRITE);
2766 15104686 bool advancetile = script_hero_sprite <= 0;
2767
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8530316 times.
✓ Branch 3 taken 6574370 times.
15104686 switch(zinit.heroAnimationStyle)
2768 {
2769 case las_original: //normal
2770
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 8527148 times.
8530316 if(action==drowning)
2771 {
2772
1/2
✓ Branch 0 taken 3168 times.
✗ Branch 1 not taken.
3168 if(inwater)
2773 {
2774 3168 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3168 times.
3168 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2776 3168 }
2777 else
2778 {
2779 goto herodraw_end;
2780 }
2781 3168 }
2782
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8526892 times.
8527148 else if(action==lavadrowning)
2783 {
2784 256 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2786 256 }
2787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8526892 times.
8526892 else if(action==sidedrowning)
2788 {
2789 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2790 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2791 }
2792
2/4
✓ Branch 0 taken 8526892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8526892 times.
8526892 else if (action == sideswimming || action == sideswimhit)
2793 {
2794 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2795
2796 if(lstep>=6)
2797 {
2798 if(dir==up)
2799 {
2800 if(advancetile) ++flip;
2801 }
2802 else
2803 {
2804 if(advancetile) extend==2?tile+=2:++tile;
2805 }
2806 }
2807 }
2808
5/6
✓ Branch 0 taken 8432255 times.
✓ Branch 1 taken 94637 times.
✓ Branch 2 taken 8431434 times.
✓ Branch 3 taken 821 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8431434 times.
8526892 else if(action==swimming || action==swimhit || hopclk==0xFF)
2809 {
2810 95458 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2811
2812
2/2
✓ Branch 0 taken 47669 times.
✓ Branch 1 taken 47789 times.
95458 if(lstep>=6)
2813 {
2814
2/2
✓ Branch 0 taken 9775 times.
✓ Branch 1 taken 38014 times.
47789 if(dir==up)
2815 {
2816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9775 times.
9775 if(advancetile) ++flip;
2817 9775 }
2818 else
2819 {
2820
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38014 times.
38014 if(advancetile) extend==2?tile+=2:++tile;
2821 }
2822 47789 }
2823
2824
2/2
✓ Branch 0 taken 90255 times.
✓ Branch 1 taken 5203 times.
95458 if(isDiving())
2825 {
2826 5203 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5203 times.
5203 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2828 5203 }
2829 95458 }
2830
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 8429816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
8431434 else if(charging > 0 && attack != wHammer)
2831 {
2832 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2833
2834
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2835 {
2836
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2837 {
2838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(advancetile) ++flip;
2839 144 }
2840 else
2841 {
2842
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if(advancetile) extend==2?tile+=2:++tile;
2843 }
2844 675 }
2845 1618 }
2846
9/12
✓ Branch 0 taken 8429574 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 8429574 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 108445 times.
✓ Branch 5 taken 8321371 times.
✓ Branch 6 taken 90047 times.
✓ Branch 7 taken 18398 times.
✓ Branch 8 taken 90047 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 90047 times.
8429816 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2847 {
2848 90047 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90047 times.
90047 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2850 90047 }
2851
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 8337879 times.
8339769 else if(fallclk>0)
2852 {
2853 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2855 1890 }
2856
5/6
✓ Branch 0 taken 419450 times.
✓ Branch 1 taken 7918429 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 418865 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 585 times.
8337879 else if(!noliftspr&&action==lifting&&isLifting())
2857 {
2858 585 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(script_hero_sprite <= 0)
2860 {
2861 585 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2862 585 auto speed = tliftclk/frames;
2863
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (speed < 1) speed = 1;
2864 585 auto curframe = (tliftclk - liftclk) / speed;
2865
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (!tliftclk) curframe = frames - 1;
2866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(unsigned(curframe) < frames)
2867 585 tile += curframe * (extend == 2 ? 2 : 1);
2868 585 }
2869 585 }
2870 else
2871 {
2872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8337294 times.
8337294 if(IsSideSwim())
2873 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2874 else
2875 {
2876
4/4
✓ Branch 0 taken 418865 times.
✓ Branch 1 taken 7918429 times.
✓ Branch 2 taken 410269 times.
✓ Branch 3 taken 8596 times.
8337294 if(!noliftspr&&isLifting())
2877 8596 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2878 8328698 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2879 }
2880
2881
2/2
✓ Branch 0 taken 6190421 times.
✓ Branch 1 taken 2146873 times.
8337294 if(dir>up)
2882 {
2883 6190421 useltm=true;
2884 6190421 }
2885
2886
3/4
✓ Branch 0 taken 8337294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4060418 times.
✓ Branch 3 taken 4276876 times.
8337294 if(advancetile && lstep>=6)
2887 {
2888
2/2
✓ Branch 0 taken 1092635 times.
✓ Branch 1 taken 3184241 times.
4276876 if(dir==up)
2889 {
2890 1092635 ++flip;
2891 1092635 }
2892 else
2893 {
2894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3184241 times.
3184241 extend==2?tile+=2:++tile;
2895 }
2896 4276876 }
2897 }
2898
2899 8530316 break;
2900
2901 case las_bszelda: //BS
2902
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 6571426 times.
6574370 if(action==drowning)
2903 {
2904
1/2
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
2944 if(inwater)
2905 {
2906 2944 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2944 times.
2944 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2908 2944 }
2909 else
2910 {
2911 goto herodraw_end;
2912 }
2913 2944 }
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6571426 times.
6571426 else if (action == sidedrowning)
2915 {
2916 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2917 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2918 }
2919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6571426 times.
6571426 else if(action==lavadrowning)
2920 {
2921 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2922 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2923 }
2924
2/4
✓ Branch 0 taken 6571426 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6571426 times.
6571426 else if (action == sideswimming || action == sideswimhit)
2925 {
2926 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2927
2928 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2929 }
2930
6/6
✓ Branch 0 taken 6509782 times.
✓ Branch 1 taken 61644 times.
✓ Branch 2 taken 6509351 times.
✓ Branch 3 taken 431 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 6509194 times.
6571426 else if(action==swimming || action==swimhit || hopclk==0xFF)
2931 {
2932
2/2
✓ Branch 0 taken 15239 times.
✓ Branch 1 taken 46993 times.
62232 if (get_qr(qr_COPIED_SWIM_SPRITES))
2933 {
2934 15239 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2935 15239 }
2936 else
2937 {
2938 46993 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2939 }
2940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62232 times.
62232 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2941
2942
2/2
✓ Branch 0 taken 56358 times.
✓ Branch 1 taken 5874 times.
62232 if(isDiving())
2943 {
2944
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 5034 times.
5874 if (get_qr(qr_COPIED_SWIM_SPRITES))
2945 {
2946 840 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2947 840 }
2948 else
2949 {
2950 5034 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2951 }
2952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874 times.
5874 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2953 5874 }
2954 62232 }
2955
3/4
✓ Branch 0 taken 32285 times.
✓ Branch 1 taken 6476909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32285 times.
6509194 else if(charging > 0 && attack != wHammer)
2956 {
2957 32285 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32285 times.
32285 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2959 32285 }
2960
8/10
✓ Branch 0 taken 6457398 times.
✓ Branch 1 taken 19511 times.
✓ Branch 2 taken 6457398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19151 times.
✓ Branch 5 taken 6457758 times.
✓ Branch 6 taken 12105 times.
✓ Branch 7 taken 7046 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 12105 times.
6476909 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2961 {
2962 12105 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2963
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 12036 times.
12105 if(advancetile) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2964 12105 }
2965
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 6463124 times.
6464804 else if(fallclk>0)
2966 {
2967 1680 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(advancetile) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2969 1680 }
2970
5/6
✓ Branch 0 taken 410730 times.
✓ Branch 1 taken 6052394 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 410441 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 289 times.
6463124 else if(!noliftspr&&action==lifting&&isLifting())
2971 {
2972 289 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if(script_hero_sprite <= 0)
2974 {
2975 289 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2976 289 auto speed = tliftclk/frames;
2977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if (speed < 1) speed = 1;
2978 289 auto curframe = (tliftclk - liftclk) / speed;
2979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if (!tliftclk) curframe = frames - 1;
2980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if(unsigned(curframe) < frames)
2981 289 tile += curframe * (extend == 2 ? 2 : 1);
2982 289 }
2983 289 }
2984 else
2985 {
2986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6462835 times.
6462835 if(IsSideSwim())
2987 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2988 else
2989 {
2990
4/4
✓ Branch 0 taken 410441 times.
✓ Branch 1 taken 6052394 times.
✓ Branch 2 taken 408702 times.
✓ Branch 3 taken 1739 times.
6462835 if(!noliftspr&&isLifting())
2991 1739 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2992 6461096 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2993 }
2994
2995
2/2
✓ Branch 0 taken 1839670 times.
✓ Branch 1 taken 4623165 times.
6462835 if(dir > up)
2996 {
2997 4623165 useltm=true;
2998 4623165 }
2999
2/2
✓ Branch 0 taken 7693 times.
✓ Branch 1 taken 6455142 times.
6462835 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3000 }
3001
3002 6574370 break;
3003
3004 case las_zelda3slow: //8-frame Zelda 3 (slow)
3005 case las_zelda3: //8-frame Zelda 3
3006 if(action == drowning)
3007 {
3008 if(inwater)
3009 {
3010 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
3011 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3012 }
3013 else
3014 {
3015 goto herodraw_end;
3016 }
3017 }
3018 else if(action == lavadrowning)
3019 {
3020 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
3021 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3022
3023 }
3024 else if(action == sidedrowning)
3025 {
3026 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
3027 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3028 }
3029 else if (action == sideswimming || action == sideswimhit)
3030 {
3031 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3032
3033 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3034 }
3035 else if(action == swimming || action==swimhit || hopclk==0xFF)
3036 {
3037 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
3038 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3039
3040 if(isDiving())
3041 {
3042 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
3043 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3044 }
3045 }
3046 else if(charging > 0 && attack != wHammer)
3047 {
3048 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
3049 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
3050 //int32_t l=hero_count/hero_animation_speed;
3051 int32_t l=(hero_count/hero_animation_speed)&15;
3052 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
3053 l-=((l>3)?1:0)+((l>12)?1:0);
3054 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
3055 }
3056 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
3057 {
3058 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
3059 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
3060 }
3061 else if(fallclk>0)
3062 {
3063 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
3064 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
3065 }
3066 else if(!noliftspr&&action==lifting&&isLifting())
3067 {
3068 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
3069 if(script_hero_sprite <= 0)
3070 {
3071 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
3072 auto speed = tliftclk/frames;
3073 if (speed < 1) speed = 1;
3074 auto curframe = (tliftclk-liftclk)/speed;
3075 if (!tliftclk) curframe = frames - 1;
3076 if(unsigned(curframe) < frames)
3077 tile += curframe * (extend == 2 ? 2 : 1);
3078 }
3079 }
3080 else
3081 {
3082 if(IsSideSwim())
3083 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3084 else
3085 {
3086 if(!noliftspr&&isLifting())
3087 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
3088 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3089 }
3090
3091 if(advancetile && (action == walking || action == climbcoverbottom || action == climbcovertop))
3092 {
3093 tile += (extend == 2 ? 2 : 1);
3094 }
3095
3096 if(dir>up)
3097 {
3098 useltm=true;
3099 }
3100
3101 if(advancetile && (action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop))
3102 {
3103 //tile+=(extend==2?2:1);
3104 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
3105 int32_t l = hero_count / hero_animation_speed;
3106 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
3107 tile += (l / 2) * (extend == 2 ? 2 : 1);
3108 }
3109 }
3110
3111 break;
3112
3113 default:
3114 break;
3115 }
3116 15104686 }
3117
3118
6/6
✓ Branch 0 taken 6694724 times.
✓ Branch 1 taken 8412809 times.
✓ Branch 2 taken 4246862 times.
✓ Branch 3 taken 2447862 times.
✓ Branch 4 taken 170841 times.
✓ Branch 5 taken 4076021 times.
15107533 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3119
3120
2/2
✓ Branch 0 taken 15104229 times.
✓ Branch 1 taken 3304 times.
15107533 if(action==won)
3121 {
3122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3304 times.
3304 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
3123 3304 }
3124
3125
4/4
✓ Branch 0 taken 14948873 times.
✓ Branch 1 taken 158660 times.
✓ Branch 2 taken 93472 times.
✓ Branch 3 taken 14855401 times.
15107533 if(action==landhold1 || action==landhold2)
3126 {
3127 252132 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3128
6/6
✓ Branch 0 taken 106891 times.
✓ Branch 1 taken 145241 times.
✓ Branch 2 taken 80905 times.
✓ Branch 3 taken 25986 times.
✓ Branch 4 taken 14607 times.
✓ Branch 5 taken 66298 times.
252132 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3129 252132 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
3130 252132 }
3131
4/4
✓ Branch 0 taken 14854046 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14853187 times.
14855401 else if(action==waterhold1 || action==waterhold2)
3132 {
3133 2214 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3134 2214 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
3135 2214 }
3136
2/4
✓ Branch 0 taken 14853187 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14853187 times.
14853187 else if(action==sidewaterhold1 || action==sidewaterhold2)
3137 {
3138 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3139 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
3140 }
3141
3142
3/4
✓ Branch 0 taken 15104686 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15104686 times.
15107533 if(action!=casting && action!=sideswimcasting)
3143 {
3144
2/2
✓ Branch 0 taken 2634525 times.
✓ Branch 1 taken 12470161 times.
15104686 if(useltm)
3145 {
3146
2/2
✓ Branch 0 taken 7762 times.
✓ Branch 1 taken 12462399 times.
12470161 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
3147 12470161 }
3148 15104686 }
3149
3150 // Stone of Agony
3151
1/2
✓ Branch 0 taken 15107533 times.
✗ Branch 1 not taken.
15107533 if(agony)
3152 {
3153 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
3154 }
3155
3156
2/2
✓ Branch 0 taken 63595 times.
✓ Branch 1 taken 15043938 times.
15107533 if(is_hitflickerframe())
3157 {
3158
4/6
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 63414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 63414 times.
63595 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
3159
2/4
✓ Branch 0 taken 63595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63595 times.
✗ Branch 3 not taken.
63595 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
3160 {
3161 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
3162 sprite_flicker_color = temp_flicker_color;
3163 masked_draw(dest);
3164 }
3165 63595 }
3166 else
3167 15043938 masked_draw(dest);
3168
3169 //draw held items after Hero so they don't go behind his head
3170
4/4
✓ Branch 0 taken 14948873 times.
✓ Branch 1 taken 158660 times.
✓ Branch 2 taken 93472 times.
✓ Branch 3 taken 14855401 times.
15107533 if(action==landhold1 || action==landhold2)
3171 {
3172
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 252110 times.
252132 if(holditem > -1)
3173 {
3174 252110 int hx = x - ((action==landhold1)?4:0);
3175 252110 int hy = y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3176
2/2
✓ Branch 0 taken 140491 times.
✓ Branch 1 taken 111619 times.
252110 if(get_qr(qr_HOLDITEMANIMATION))
3177 {
3178 140491 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3179 140491 }
3180 else
3181 {
3182 111619 putitem(dest,hx,hy,holditem);
3183 }
3184 252110 }
3185 252132 }
3186
4/4
✓ Branch 0 taken 14854046 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14853187 times.
14855401 else if(action==waterhold1 || action==waterhold2)
3187 {
3188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
2214 if(holditem > -1)
3189 {
3190 2214 int hx = x - ((action==waterhold1)?4:0);
3191 2214 int hy = y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3192
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 652 times.
2214 if(get_qr(qr_HOLDITEMANIMATION))
3193 {
3194 1562 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3195 1562 }
3196 else
3197 {
3198 652 putitem(dest,hx,hy,holditem);
3199 }
3200 2214 }
3201 2214 }
3202
2/4
✓ Branch 0 taken 14853187 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14853187 times.
14853187 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
3203 {
3204 if(holditem > -1)
3205 {
3206 int hx = x - ((action==sidewaterhold1)?4:0);
3207 int hy = y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3208 if(get_qr(qr_HOLDITEMANIMATION))
3209 {
3210 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3211 }
3212 else
3213 {
3214 putitem(dest,hx,hy,holditem);
3215 }
3216 }
3217 }
3218
4/4
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 15084279 times.
✓ Branch 2 taken 5125 times.
✓ Branch 3 taken 18129 times.
15107533 if(fairyclk==0||(get_qr(qr_NOHEARTRING)))
3219 {
3220 15089404 goto herodraw_end;
3221 }
3222
3223 18129 double a2 = fairyclk*4.5 + 90;
3224 18129 int32_t hearts=0;
3225 18129 int32_t htile = 2;
3226
3227 18129 do
3228 {
3229 110312 int32_t nx=125;
3230
3231
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3232 {
3233 46080 nx=x;
3234 46080 }
3235
3236 110312 int32_t ny=88;
3237
3238
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3239 {
3240 46080 ny=y;
3241 46080 }
3242
3243 110312 int32_t tx = zc::math::CosD(a2)*53 +nx;
3244 110312 int32_t ty = -zc::math::SinD(a2)*53 +ny+playing_field_offset;
3245 110312 overtile8(dest,htile,tx,ty,1,0);
3246 110312 a2-=45;
3247 110312 ++hearts;
3248
2/2
✓ Branch 0 taken 92183 times.
✓ Branch 1 taken 18129 times.
220624 }
3249
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 100392 times.
110312 while(a2>90 && hearts<8);
3250 18129 }
3251 herodraw_end:
3252 16873361 xofs=oxofs;
3253 16873361 yofs=oyofs;
3254 16873361 do_primitives(dest, SPLAYER_PLAYER_DRAW);
3255 16873361 }
3256
3257 16519179 void HeroClass::masked_draw(BITMAP* dest)
3258 {
3259 // The first sprite::draw in this function uses sprite_flicker_color
3260 // This is intended to be the player, handle this if this changes. -Moosh
3261 16519179 zfix lz, lfz;
3262
2/2
✓ Branch 0 taken 16507970 times.
✓ Branch 1 taken 11209 times.
16519179 if(lift_wpn)
3263 {
3264 11209 lz = lift_wpn->z;
3265 11209 lfz = lift_wpn->fakez;
3266 11209 }
3267
3268
12/12
✓ Branch 0 taken 6913027 times.
✓ Branch 1 taken 9606152 times.
✓ Branch 2 taken 6666809 times.
✓ Branch 3 taken 246218 times.
✓ Branch 4 taken 6515961 times.
✓ Branch 5 taken 150848 times.
✓ Branch 6 taken 6354501 times.
✓ Branch 7 taken 161460 times.
✓ Branch 8 taken 6161041 times.
✓ Branch 9 taken 193460 times.
✓ Branch 10 taken 6464852 times.
✓ Branch 11 taken 201957 times.
16519179 if(isdungeon() && cur_screen<128 && (x<16 || x>(world_w-32) || y<18 || y>(world_h-30)) && !get_qr(qr_FREEFORM))
3269 {
3270 // clip under doorways
3271 201957 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3272
3273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(sub!=NULL)
3274 {
3275 201957 yofs -= (playing_field_offset+16);
3276 201957 xofs -= 16;
3277 201957 sprite::draw(sub);
3278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(lift_wpn)
3279 {
3280 handle_lift(false);
3281 bool shad = lift_wpn->has_shadow;
3282 lift_wpn->has_shadow = false;
3283 lift_wpn->z += z;
3284 lift_wpn->fakez += fakez;
3285 lift_wpn->draw(sub);
3286 lift_wpn->has_shadow = shad;
3287 }
3288 201957 prompt_draw(sub);
3289 201957 xofs+=16;
3290 201957 yofs += (playing_field_offset+16);
3291 201957 destroy_bitmap(sub);
3292 201957 }
3293 201957 }
3294 else
3295 {
3296 16317222 sprite::draw(dest);
3297
2/2
✓ Branch 0 taken 16306013 times.
✓ Branch 1 taken 11209 times.
16317222 if(lift_wpn)
3298 {
3299 11209 handle_lift(false);
3300 11209 bool shad = lift_wpn->has_shadow;
3301 11209 lift_wpn->has_shadow = false;
3302 11209 lift_wpn->z += z;
3303 11209 lift_wpn->fakez += fakez;
3304 11209 lift_wpn->draw(dest);
3305 11209 lift_wpn->has_shadow = shad;
3306 11209 }
3307 16317222 prompt_draw(dest);
3308 }
3309
3310
2/2
✓ Branch 0 taken 16507970 times.
✓ Branch 1 taken 11209 times.
16519179 if(lift_wpn)
3311 {
3312 11209 lift_wpn->z = lz;
3313 11209 lift_wpn->fakez = lfz;
3314 11209 }
3315 16519179 return;
3316 }
3317 16519179 void HeroClass::prompt_draw(BITMAP* dest)
3318 {
3319
2/2
✓ Branch 0 taken 9958 times.
✓ Branch 1 taken 16509221 times.
16519179 if(!prompt_combo) return;
3320 9958 int32_t sx = real_x(x+xofs+prompt_x);
3321 9958 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3322 9958 sy -= fake_z(fakez);
3323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9958 times.
9958 if(combobuf[prompt_combo].animflags & AF_EDITOR_ONLY) return;
3324 9958 overcombo(dest, sx - viewport.x, sy - viewport.y, prompt_combo, prompt_cset);
3325 9958 return;
3326 16519179 }
3327
3328 21384 void collectitem_script(int32_t id)
3329 {
3330
2/2
✓ Branch 0 taken 21077 times.
✓ Branch 1 taken 307 times.
21384 if(itemsbuf[id].collect_script)
3331 {
3332 //clear item script stack.
3333 307 FFCore.clear_ref(ScriptType::Item, -id);
3334
3335
2/6
✓ Branch 0 taken 307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 307 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
307 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3336 {
3337 307 int i = -id;
3338 307 FFCore.reset_script_engine_data(ScriptType::Item, i);
3339 307 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3340 307 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3341 307 }
3342 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3343 {
3344 int i = COLLECT_SCRIPT_ITEM_ZERO;
3345 FFCore.reset_script_engine_data(ScriptType::Item, i);
3346 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3347 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3348 }
3349 //runningItemScripts[id] = 0;
3350 307 }
3351 21384 }
3352 4169 void passiveitem_script(int32_t id, bool doRun = false)
3353 {
3354 //Passive item scripts on colelction
3355
3/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 4104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4169 if(itemsbuf[id].script && ( (itemsbuf[id].flags&item_passive_script) && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ))
3356 {
3357 FFCore.reset_script_engine_data(ScriptType::Item, id);
3358
3359 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3360 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3361 {
3362 FFCore.doscript(ScriptType::Item, id) = false;
3363 return;
3364 }
3365 if(doRun)
3366 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3367 }
3368 4169 }
3369
3370 // separate case for sword/wand/hammer/slashed weapons only
3371 // the main weapon checking is in the global function check_collisions()
3372 14307770 bool HeroClass::checkstab()
3373 {
3374
14/14
✓ Branch 0 taken 12679947 times.
✓ Branch 1 taken 1627823 times.
✓ Branch 2 taken 365015 times.
✓ Branch 3 taken 1262808 times.
✓ Branch 4 taken 339546 times.
✓ Branch 5 taken 25469 times.
✓ Branch 6 taken 275127 times.
✓ Branch 7 taken 64419 times.
✓ Branch 8 taken 275099 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 253729 times.
✓ Branch 11 taken 21370 times.
✓ Branch 12 taken 376366 times.
✓ Branch 13 taken 997728 times.
14307770 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3375 1627823 || (attackclk<=4))
3376 13310042 return false;
3377
3378 997728 weapon *w=NULL;
3379
3380 997728 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3381 997728 bool found = false;
3382 997728 int32_t melee_weapon_index = 0;
3383 997728 int32_t parentitem=-1;
3384 997728 weapon* meleeweap = nullptr;
3385
2/2
✓ Branch 0 taken 60656 times.
✓ Branch 1 taken 1108417 times.
1169073 for(int32_t i=0; i<Lwpns.Count(); i++)
3386 {
3387 1108417 w = (weapon*)Lwpns.spr(i);
3388
3389
6/6
✓ Branch 0 taken 1108379 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 19045 times.
✓ Branch 3 taken 1089334 times.
✓ Branch 4 taken 171345 times.
✓ Branch 5 taken 937072 times.
1108417 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3390 {
3391 937072 found = true;
3392 937072 melee_weapon_index = i+1;
3393 937072 meleeweap = w;
3394 // Position the sword as Hero slashes with it.
3395
4/4
✓ Branch 0 taken 881644 times.
✓ Branch 1 taken 55428 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 881530 times.
937072 if(w->id!=wHammer&&w->id!=wBugNet)
3396 881530 positionSword(w,w->parentitem);
3397
3398 937072 wx=w->x;
3399 937072 wy=w->y;
3400 937072 wz=w->z;
3401 937072 wxsz = w->hit_width;
3402 937072 wysz = w->hit_height;
3403 937072 parentitem = w->parentitem;
3404 937072 break;
3405 }
3406 171345 }
3407
3408
6/6
✓ Branch 0 taken 909327 times.
✓ Branch 1 taken 88401 times.
✓ Branch 2 taken 135406 times.
✓ Branch 3 taken 773921 times.
✓ Branch 4 taken 39264 times.
✓ Branch 5 taken 96142 times.
997728 if(attack==wSword && attackclk>=14 && charging==0)
3409 96142 return false;
3410
3411
2/2
✓ Branch 0 taken 840930 times.
✓ Branch 1 taken 60656 times.
901586 if(!found)
3412 60656 return false;
3413
3414
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 840507 times.
840930 if(attack == wFire)
3415 423 return false;
3416
3417
2/2
✓ Branch 0 taken 785079 times.
✓ Branch 1 taken 55428 times.
840507 if(attack==wHammer)
3418 {
3419
2/2
✓ Branch 0 taken 21966 times.
✓ Branch 1 taken 33462 times.
55428 if(attackclk<15)
3420 {
3421
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✓ Branch 2 taken 5263 times.
✓ Branch 3 taken 7217 times.
✓ Branch 4 taken 6059 times.
21966 switch(w->dir)
3422 {
3423 case up:
3424 3427 wx=x-1;
3425 3427 wy=y-4;
3426 3427 break;
3427
3428 case down:
3429 5263 wx=x+8;
3430 5263 wy=y+28;
3431 5263 break; // This is consistent with 2.10
3432
3433 case left:
3434 7217 wx=x-13;
3435 7217 wy=y+14;
3436 7217 break;
3437
3438 case right:
3439 6059 wx=x+21;
3440 6059 wy=y+14;
3441 6059 break;
3442 }
3443
3444
6/8
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 19794 times.
✓ Branch 2 taken 2172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2172 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2167 times.
21966 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3445 {
3446 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3447 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3448 switch(dir)
3449 {
3450 case up:
3451 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3452 break;
3453
3454 case down:
3455 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3456 break;
3457
3458 case left:
3459 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3460 break;
3461
3462 case right:
3463 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3464 break;
3465 }
3466 */
3467 2167 }
3468
3469 21966 return false;
3470 }
3471
2/2
✓ Branch 0 taken 31330 times.
✓ Branch 1 taken 2132 times.
33462 else if(attackclk==15)
3472 {
3473 // Hammer's reach needs adjusted slightly for backward compatibility
3474
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 337 times.
2132 if(w->dir==up)
3475 337 w->hyofs-=1;
3476
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 698 times.
1795 else if(w->dir==left)
3477 698 w->hxofs-=2;
3478 2132 }
3479 33462 }
3480
3481 // The return of Spaghetti Code Constants!
3482
6/6
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 802244 times.
✓ Branch 2 taken 768650 times.
✓ Branch 3 taken 33594 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 33576 times.
818541 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3483
4/4
✓ Branch 0 taken 84445 times.
✓ Branch 1 taken 734096 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 84417 times.
818541 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3484 818541 itemid = vbound(itemid, 0, MAXITEMS-1);
3485
3486 // The sword offsets aren't based on anything other than what felt about right
3487 // compared to the NES game and what mostly kept it from hitting things that
3488 // should clearly be out of range. They could probably still use more tweaking.
3489 // Don't use 2.10 for reference; it's pretty far off.
3490 // - Saf
3491
3492
6/6
✓ Branch 0 taken 436104 times.
✓ Branch 1 taken 382437 times.
✓ Branch 2 taken 24782 times.
✓ Branch 3 taken 411322 times.
✓ Branch 4 taken 408480 times.
✓ Branch 5 taken 27624 times.
818541 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & item_flag4)
3493 {
3494
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 71025 times.
✓ Branch 2 taken 89454 times.
✓ Branch 3 taken 125856 times.
✓ Branch 4 taken 122145 times.
408480 switch(w->dir)
3495 {
3496 case up:
3497
2/2
✓ Branch 0 taken 48514 times.
✓ Branch 1 taken 22511 times.
71025 if(attackclk<8)
3498 {
3499 22511 wy-=4;
3500 22511 }
3501
3502 71025 break;
3503
3504 case down:
3505 //if(attackclk<8)
3506 {
3507 89454 wy-=2;
3508 }
3509 89454 break;
3510
3511 case left:
3512
3513 //if(attackclk<8)
3514 {
3515 125856 wx+=2;
3516 }
3517
3518 125856 break;
3519
3520 case right:
3521
3522 //if(attackclk<8)
3523 {
3524 122145 wx-=3;
3525 //wy+=((spins>0 || get_qr(qr_SLASHFLIPFIX)) ? -4 : 4);
3526 }
3527
3528 122145 break;
3529 }
3530 408480 }
3531
3532
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 165605 times.
✓ Branch 2 taken 176608 times.
✓ Branch 3 taken 237908 times.
✓ Branch 4 taken 238420 times.
818541 switch(w->dir)
3533 {
3534 case up:
3535 165605 wx+=2;
3536 165605 break;
3537
3538 case down:
3539 176608 break;
3540
3541 case left:
3542 237908 wy-=3;
3543 237908 break;
3544
3545 case right:
3546 238420 wy-=3;
3547 238420 break;
3548 }
3549
3550 818541 wx+=w->hxofs;
3551 818541 wy+=w->hyofs;
3552 818541 wy-=(w->fakez).getInt();
3553
3554
2/2
✓ Branch 0 taken 812112 times.
✓ Branch 1 taken 3502887 times.
4314999 for(int32_t i=0; i<guys.Count(); i++)
3555 {
3556
2/2
✓ Branch 0 taken 3502792 times.
✓ Branch 1 taken 95 times.
3502887 if(attack==wBugNet) break;
3557 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3558
6/6
✓ Branch 0 taken 74476 times.
✓ Branch 1 taken 3428316 times.
✓ Branch 2 taken 73881 times.
✓ Branch 3 taken 595 times.
✓ Branch 4 taken 72186 times.
✓ Branch 5 taken 1695 times.
3503348 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & item_flag3)))
3559
5/6
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2524 times.
✓ Branch 2 taken 3325176 times.
✓ Branch 3 taken 103848 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3429024 times.
3430606 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & item_flag3))
3560
4/4
✓ Branch 0 taken 120275 times.
✓ Branch 1 taken 3308749 times.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 119719 times.
3429024 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & item_flag3)))
3561 {
3562 // Checking the whimsical ring for every collision check causes
3563 // an odd bug. It's much more likely to activate on a 0-damage
3564 // weapon, since a 0-damage hit won't make the enemy invulnerable
3565 // to damaging hits in the following frames.
3566
3567 74710 int32_t whimsyid = current_item_id(itype_whimsicalring);
3568
3569 74710 int32_t dmg = weaponattackpower(itemid);
3570
2/2
✓ Branch 0 taken 72801 times.
✓ Branch 1 taken 1909 times.
74710 if(whimsyid>-1)
3571 {
3572
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3573 116 dmg += current_item_power(itype_whimsicalring);
3574 1793 else whimsyid = -1;
3575 1909 }
3576 74710 int32_t atkringid = current_item_id(itype_atkring);
3577
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 74702 times.
74710 if(atkringid>-1)
3578 {
3579 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3580 8 dmg += itemsbuf[atkringid].misc1; //Additive
3581 8 }
3582
3583 74710 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3584 74710 enemy *e = (enemy*)guys.spr(i);
3585
2/2
✓ Branch 0 taken 19817 times.
✓ Branch 1 taken 54893 times.
74710 if (h < 0)
3586 {
3587 54893 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3588 54893 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
3589 54893 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3590
1/2
✓ Branch 0 taken 54893 times.
✗ Branch 1 not taken.
54893 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3591 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3592 54893 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3593 54893 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3594 54893 } //temp_hit = true; }
3595 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3596
3597
4/4
✓ Branch 0 taken 54893 times.
✓ Branch 1 taken 19817 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 54818 times.
74710 if(h<0 && whimsyid>-1)
3598 {
3599 75 sfx(itemsbuf[whimsyid].usesound);
3600 75 }
3601
3602
4/4
✓ Branch 0 taken 63441 times.
✓ Branch 1 taken 11269 times.
✓ Branch 2 taken 62961 times.
✓ Branch 3 taken 480 times.
74710 if(h && charging>0)
3603 {
3604 480 attackclk = SWORDTAPFRAME;
3605 480 spins=0;
3606 480 }
3607
3608
8/8
✓ Branch 0 taken 63441 times.
✓ Branch 1 taken 11269 times.
✓ Branch 2 taken 53759 times.
✓ Branch 3 taken 9682 times.
✓ Branch 4 taken 53725 times.
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 1217 times.
✓ Branch 7 taken 52508 times.
74710 if(h && hclk==0 && inlikelike != 1 && !get_qr(qr_DYING_ENEMIES_IGNORE_STUN))
3609 {
3610
2/2
✓ Branch 0 taken 52351 times.
✓ Branch 1 taken 157 times.
52508 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3611 {
3612 157 hithero(i);
3613 157 }
3614 52508 }
3615
3616
2/2
✓ Branch 0 taken 67434 times.
✓ Branch 1 taken 7276 times.
74710 if(abs(h)==2)
3617 7276 break;
3618 67434 }
3619 3496458 }
3620
3621
2/2
✓ Branch 0 taken 18938 times.
✓ Branch 1 taken 799489 times.
1637910 if(attack == wBugNet
3622
3/4
✓ Branch 0 taken 818427 times.
✓ Branch 1 taken 1056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 818427 times.
819483 || (parentitem==-1&&!get_qr(qr_NOITEMMELEE))
3623
1/2
✓ Branch 0 taken 818427 times.
✗ Branch 1 not taken.
818427 || (parentitem>-1&&!(itemsbuf[parentitem].flags & item_flag7)))
3624 {
3625
3/4
✓ Branch 0 taken 800431 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
800545 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3626
2/2
✓ Branch 0 taken 800545 times.
✓ Branch 1 taken 256564 times.
1057109 for(int32_t j=0; j<items.Count(); j++)
3627 {
3628 256564 item* ptr = (item*)items.spr(j);
3629
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 256544 times.
256565 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3630
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
20 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & item_flag1));
3631
3632
2/4
✓ Branch 0 taken 256564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256564 times.
✗ Branch 3 not taken.
256564 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3633 continue; //No picking these up unless you have a bottle to fill!
3634
5/6
✓ Branch 0 taken 256537 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 48597 times.
✓ Branch 3 taken 207940 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48597 times.
256564 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3635 {
3636
7/8
✓ Branch 0 taken 207940 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 97068 times.
✓ Branch 3 taken 110872 times.
✓ Branch 4 taken 110899 times.
✓ Branch 5 taken 97068 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110899 times.
207967 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3637 {
3638
6/6
✓ Branch 0 taken 103964 times.
✓ Branch 1 taken 6935 times.
✓ Branch 2 taken 981 times.
✓ Branch 3 taken 102983 times.
✓ Branch 4 taken 103949 times.
✓ Branch 5 taken 6950 times.
214860 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3639
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 101210 times.
✓ Branch 3 taken 2751 times.
103964 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3640 {
3641 6950 int screen = get_screen_for_world_xy(wx, wy);
3642 6950 mapscr* scr = get_scr_for_world_xy(wx, wy);
3643 6950 int32_t pickup = ptr->pickup;
3644 6950 int32_t id2 = ptr->id;
3645 6950 int32_t pstr = ptr->pstring;
3646 6950 int32_t pstr_flags = ptr->pickup_string_flags;
3647 6950 int32_t pstr_screen = ptr->screen_spawned;
3648
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6949 times.
6950 if(!dofairy)
3649 {
3650 6949 std::vector<int32_t> &ev = FFCore.eventData;
3651 6949 ev.clear();
3652 6949 ev.push_back(id2*10000);
3653 6949 ev.push_back(pickup*10000);
3654 6949 ev.push_back(pstr*10000);
3655 6949 ev.push_back(pstr_flags*10000);
3656 6949 ev.push_back(0);
3657 6949 ev.push_back(ptr->getUID());
3658 6949 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3659 6949 ev.push_back(w->getUID());
3660
3661 6949 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3662 6949 bool nullify = ev[4] != 0;
3663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6949 times.
6949 if(nullify) continue;
3664 6949 id2 = ev[0]/10000;
3665 6949 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3666 6949 pstr = ev[2] / 10000;
3667 6949 pstr_flags = ev[3] / 10000;
3668 6949 }
3669
3670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
6950 if(pickup&ipONETIME) // set mITEM for one-time-only items
3671 setmapflag(scr, mITEM);
3672
1/2
✓ Branch 0 taken 6950 times.
✗ Branch 1 not taken.
6950 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3673 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3674
3675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6950 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3676 setxmapflag(screen, 1<<ptr->pickupexstate);
3677
1/2
✓ Branch 0 taken 6950 times.
✗ Branch 1 not taken.
6950 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3678 {
3679 if (scr->flags9&fITEMSECRETPERM) setmapflag(scr, mSECRET);
3680 trigger_secrets_for_screen(TriggerSource::ItemsSecret, scr, false);
3681 }
3682 //!DIMI
3683
3684
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6949 times.
6950 if(dofairy)
3685 {
3686 1 game->fillBottle(itemsbuf[ptr->id].misc4);
3687 1 }
3688 else
3689 {
3690 6949 collectitem_script(id2);
3691
3692 6949 getitem(id2, ptr->noSound, true);
3693 }
3694 6950 items.del(j);
3695
3696
2/2
✓ Branch 0 taken 8006 times.
✓ Branch 1 taken 6950 times.
14956 for(int32_t i=0; i<Lwpns.Count(); i++)
3697 {
3698 8006 weapon *w2 = (weapon*)Lwpns.spr(i);
3699
3700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
8006 if(w2->dragging==j)
3701 {
3702 w2->dragging=-1;
3703 }
3704
1/2
✓ Branch 0 taken 8006 times.
✗ Branch 1 not taken.
8006 else if(w2->dragging>j)
3705 {
3706 w2->dragging-=1;
3707 }
3708 8006 }
3709
3710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6950 if ( (pstr > 0 && pstr < msg_count) )
3711 {
3712 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3713 {
3714 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3715 FFCore.SetItemMessagePlayed(id2);
3716 donewmsg(get_scr(pstr_screen), pstr);
3717 break;
3718 }
3719 }
3720
3721 6950 --j;
3722 6950 }
3723 110899 }
3724 207967 }
3725 256564 }
3726 800545 }
3727
3728
4/4
✓ Branch 0 taken 818523 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 818409 times.
819483 if(attack==wCByrna || attack==wBugNet)
3729 1074 return false;
3730
3731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 818409 times.
818409 if(meleeweap->no_triggers())
3732 return false;
3733
3734
2/2
✓ Branch 0 taken 768650 times.
✓ Branch 1 taken 49759 times.
818409 if(attack==wSword)
3735 {
3736
2/2
✓ Branch 0 taken 681986 times.
✓ Branch 1 taken 86664 times.
768650 if(attackclk == 6)
3737 {
3738
2/2
✓ Branch 0 taken 15252864 times.
✓ Branch 1 taken 86664 times.
15339528 for(int32_t q=0; q<176; q++)
3739 {
3740 15252864 set_bit(screengrid,q,0);
3741 15252864 set_bit(screengrid_layer[0],q,0);
3742 15252864 set_bit(screengrid_layer[1],q,0);
3743 15252864 }
3744
3745 2731808 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
3746 2645144 ffc_handle.ffc->recently_hit = false;
3747 2645144 });
3748 86664 }
3749
3750
4/4
✓ Branch 0 taken 157230 times.
✓ Branch 1 taken 611420 times.
✓ Branch 2 taken 72549 times.
✓ Branch 3 taken 84681 times.
768650 if(dir==up && ((x.getInt()&15)==0))
3751 {
3752 72549 check_slash_block(wx,wy);
3753 72549 check_slash_block(wx,wy+8);
3754
3755 //layers
3756 72549 check_slash_block_layer(wx,wy,1);
3757 72549 check_slash_block_layer(wx,wy+8,1);
3758 72549 check_slash_block_layer(wx,wy,1);
3759 72549 check_slash_block_layer(wx,wy+8,1);
3760 //2
3761 72549 check_slash_block_layer(wx,wy,2);
3762 72549 check_slash_block_layer(wx,wy+8,2);
3763 72549 check_slash_block_layer(wx,wy,2);
3764 72549 check_slash_block_layer(wx,wy+8,2);
3765 72549 }
3766
8/10
✓ Branch 0 taken 84681 times.
✓ Branch 1 taken 611420 times.
✓ Branch 2 taken 26457 times.
✓ Branch 3 taken 58224 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 26217 times.
✓ Branch 6 taken 240 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 240 times.
696101 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3767 {
3768 84441 check_slash_block(wx,wy);
3769 84441 check_slash_block(wx,wy+8);
3770 84441 check_slash_block(wx+8,wy);
3771 84441 check_slash_block(wx+8,wy+8);
3772 ///layer 1
3773 84441 check_slash_block_layer(wx,wy,1);
3774 84441 check_slash_block_layer(wx,wy+8,1);
3775 84441 check_slash_block_layer(wx+8,wy,1);
3776 84441 check_slash_block_layer(wx+8,wy+8,1);
3777 ///layer 2
3778 84441 check_slash_block_layer(wx,wy,2);
3779 84441 check_slash_block_layer(wx,wy+8,2);
3780 84441 check_slash_block_layer(wx+8,wy,2);
3781 84441 check_slash_block_layer(wx+8,wy+8,2);
3782 84441 }
3783
4/4
✓ Branch 0 taken 166158 times.
✓ Branch 1 taken 602492 times.
✓ Branch 2 taken 87048 times.
✓ Branch 3 taken 79110 times.
768650 if(dir==down && ((x.getInt()&15)==0))
3784 {
3785 79110 check_slash_block(wx,wy+wysz-8);
3786 79110 check_slash_block(wx,wy+wysz);
3787
3788 //layer 1
3789 79110 check_slash_block_layer(wx,wy+wysz-8,1);
3790 79110 check_slash_block_layer(wx,wy+wysz,1);
3791 //layer 2
3792 79110 check_slash_block_layer(wx,wy+wysz-8,2);
3793 79110 check_slash_block_layer(wx,wy+wysz,2);
3794 79110 }
3795
8/10
✓ Branch 0 taken 87048 times.
✓ Branch 1 taken 602492 times.
✓ Branch 2 taken 35482 times.
✓ Branch 3 taken 51566 times.
✓ Branch 4 taken 333 times.
✓ Branch 5 taken 35149 times.
✓ Branch 6 taken 333 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 333 times.
689540 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3796 {
3797 86715 check_slash_block(wx,wy+wysz-8);
3798 86715 check_slash_block(wx,wy+wysz);
3799 86715 check_slash_block(wx+8,wy+wysz-8);
3800 86715 check_slash_block(wx+8,wy+wysz);
3801 //layer 1
3802 86715 check_slash_block_layer(wx,wy+wysz-8,1);
3803 86715 check_slash_block_layer(wx,wy+wysz,1);
3804 86715 check_slash_block_layer(wx+8,wy+wysz-8,1);
3805 86715 check_slash_block_layer(wx+8,wy+wysz,1);
3806 //layer 2
3807 86715 check_slash_block_layer(wx,wy+wysz-8,2);
3808 86715 check_slash_block_layer(wx,wy+wysz,2);
3809 86715 check_slash_block_layer(wx+8,wy+wysz-8,2);
3810 86715 check_slash_block_layer(wx+8,wy+wysz,2);
3811 86715 }
3812
3813
2/2
✓ Branch 0 taken 547830 times.
✓ Branch 1 taken 220820 times.
768650 if(dir==left)
3814 {
3815 220820 check_slash_block(wx,wy+8);
3816 220820 check_slash_block(wx+8,wy+8);
3817 //layer 1
3818 220820 check_slash_block_layer(wx,wy+8,1);
3819 220820 check_slash_block_layer(wx+8,wy+8,1);
3820 //layer 2
3821 220820 check_slash_block_layer(wx,wy+8,2);
3822 220820 check_slash_block_layer(wx+8,wy+8,2);
3823 220820 }
3824
3825
2/2
✓ Branch 0 taken 544208 times.
✓ Branch 1 taken 224442 times.
768650 if(dir==right)
3826 {
3827 224442 check_slash_block(wx+wxsz,wy+8);
3828 224442 check_slash_block(wx+wxsz-8,wy+8);
3829 //layer 1
3830 224442 check_slash_block_layer(wx+wxsz,wy+8,1);
3831 224442 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3832 //layer 2
3833 224442 check_slash_block_layer(wx+wxsz,wy+8,2);
3834 224442 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3835 224442 }
3836 768650 }
3837
2/2
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 33462 times.
49759 else if(attack==wWand)
3838 {
3839
1/2
✓ Branch 0 taken 16297 times.
✗ Branch 1 not taken.
16297 if(attackclk == 5)
3840 {
3841 for(int32_t q=0; q<176; q++)
3842 {
3843 set_bit(screengrid,q,0);
3844 set_bit(screengrid_layer[0],q,0);
3845 set_bit(screengrid_layer[1],q,0);
3846 }
3847
3848 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
3849 ffc_handle.ffc->recently_hit = false;
3850 });
3851 }
3852
3853 // cutable blocks
3854
4/4
✓ Branch 0 taken 3074 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 1386 times.
✓ Branch 3 taken 1688 times.
16297 if(dir==up && (x.getInt()&15)==0)
3855 {
3856 1386 check_wand_block(wx,wy);
3857 1386 check_wand_block(wx,wy+8);
3858 1386 }
3859
5/10
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 813 times.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
14911 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3860 {
3861 1688 check_wand_block(wx,wy);
3862 1688 check_wand_block(wx,wy+8);
3863 1688 check_wand_block(wx+8,wy);
3864 1688 check_wand_block(wx+8,wy+8);
3865 1688 }
3866
3867
4/4
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 1135 times.
✓ Branch 3 taken 1231 times.
16297 if(dir==down && (x.getInt()&15)==0)
3868 {
3869 1231 check_wand_block(wx,wy+wysz-8);
3870 1231 check_wand_block(wx,wy+wysz);
3871 1231 }
3872
5/10
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 828 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 307 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
15066 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3873 {
3874 1135 check_wand_block(wx,wy+wysz-8);
3875 1135 check_wand_block(wx,wy+wysz);
3876 1135 check_wand_block(wx+8,wy+wysz-8);
3877 1135 check_wand_block(wx+8,wy+wysz);
3878 1135 }
3879
3880
2/2
✓ Branch 0 taken 10184 times.
✓ Branch 1 taken 6113 times.
16297 if(dir==left)
3881 {
3882 6113 check_wand_block(wx,y+8);
3883 6113 check_wand_block(wx+8,y+8);
3884 6113 }
3885
3886
2/2
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 4744 times.
16297 if(dir==right)
3887 {
3888 4744 check_wand_block(wx+wxsz,y+8);
3889 4744 check_wand_block(wx+wxsz-8,y+8);
3890 4744 }
3891 16297 }
3892
4/8
✓ Branch 0 taken 33462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31330 times.
✓ Branch 3 taken 2132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31330 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
33462 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3893 {
3894 // poundable blocks
3895
2/2
✓ Branch 0 taken 375232 times.
✓ Branch 1 taken 2132 times.
377364 for(int32_t q=0; q<176; q++)
3896 {
3897 375232 set_bit(screengrid,q,0);
3898 375232 set_bit(screengrid_layer[0],q,0);
3899 375232 set_bit(screengrid_layer[1],q,0);
3900 375232 }
3901
3902 69740 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
3903 67608 ffc_handle.ffc->recently_hit = false;
3904 67608 });
3905
3906
4/4
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 164 times.
2132 if(dir==up && (x.getInt()&15)==0)
3907 {
3908 164 check_pound_block(wx,wy);
3909 164 check_pound_block(wx,wy+8);
3910 164 }
3911
5/10
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1968 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3912 {
3913 174 check_pound_block(wx,wy);
3914 174 check_pound_block(wx,wy+8);
3915 174 check_pound_block(wx+8,wy);
3916 174 check_pound_block(wx+8,wy+8);
3917 174 }
3918
3919
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 240 times.
2132 if(dir==down && (x.getInt()&15)==0)
3920 {
3921 240 check_pound_block(wx,wy+wysz-8);
3922 240 check_pound_block(wx,wy+wysz);
3923 240 }
3924
8/10
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
1892 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3925 {
3926 257 check_pound_block(wx,wy+wysz-8);
3927 257 check_pound_block(wx,wy+wysz);
3928 257 check_pound_block(wx+8,wy+wysz-8);
3929 257 check_pound_block(wx+8,wy+wysz);
3930 257 }
3931
3932
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 703 times.
2132 if(dir==left)
3933 {
3934 703 check_pound_block(wx,y+8);
3935 703 check_pound_block(wx+8,y+8);
3936 703 }
3937
3938
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 593 times.
2132 if(dir==right)
3939 {
3940 593 check_pound_block(wx+wxsz,y+8);
3941 593 check_pound_block(wx+wxsz-8,y+8);
3942 593 }
3943 2132 }
3944 31330 else return false;
3945
3946 787079 return true;
3947 14308712 }
3948
3949 4047128 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3950 {
3951
2/2
✓ Branch 0 taken 3847316 times.
✓ Branch 1 taken 199812 times.
4047128 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
3952 {
3953 3847316 return;
3954 }
3955 //keep things inside the screen boundaries
3956 199812 bx=vbound(bx, 0, world_w-1);
3957 199812 by=vbound(by, 0, world_h-1);
3958 199812 int32_t fx=bx;
3959 199812 int32_t fy=by;
3960 //first things first
3961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199812 times.
199812 if(attack!=wSword)
3962 return;
3963
3964
4/6
✓ Branch 0 taken 199812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 199812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1984 times.
✓ Branch 5 taken 20732 times.
222528 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3965
4/4
✓ Branch 0 taken 184460 times.
✓ Branch 1 taken 15352 times.
✓ Branch 2 taken 22716 times.
✓ Branch 3 taken 161744 times.
199812 || (attackclk>SWORDTAPFRAME && tapping))
3966 17336 return;
3967
3968 //find out which combo row/column the coordinates are in
3969 182476 bx = TRUNCATE_TILE(bx);
3970 182476 by = TRUNCATE_TILE(by);
3971
3972 182476 int32_t flag = MAPFLAGL(layer,bx,by);
3973 182476 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3974 182476 int32_t cid = MAPCOMBOL(layer,bx,by);
3975 182476 int32_t type = combobuf[cid].type;
3976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182476 times.
182476 if(combobuf[cid].only_gentrig)
3977 type = cNONE;
3978
3979 182476 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, layer);
3980 182476 int screen = rpos_handle.screen;
3981 182476 mapscr* s = rpos_handle.scr;
3982 182476 int i = rpos_handle.pos;
3983
3984 182476 bool ignorescreen=false;
3985
3986
4/4
✓ Branch 0 taken 181774 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 181489 times.
✓ Branch 3 taken 285 times.
182476 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3987 182191 return;
3988
3989
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
285 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3990
3991
3/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
285 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3992
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(isCuttableNextType(type))
3993 {
3994 285 s->data[i]++;
3995 285 }
3996 else
3997 {
3998 s->data[i] = s->undercombo;
3999 s->cset[i] = s->undercset;
4000 s->sflag[i] = 0;
4001 }
4002
2/8
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 285 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
285 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4003 {
4004 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4005 sfx(s->secretsfx);
4006 }
4007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 else if(isCuttableItemType(type))
4008 {
4009 285 int32_t it = -1;
4010 285 int32_t thedropset = -1;
4011
4012 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
4013
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 254 times.
285 if ( (combobuf[cid].usrflags&cflag2) )
4014 {
4015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(combobuf[cid].usrflags&cflag11)
4016 it = combobuf[cid].attribytes[1];
4017 else
4018 {
4019 31 it = select_dropitem(combobuf[cid].attribytes[1]);
4020 31 thedropset = combobuf[cid].attribytes[1];
4021 }
4022 31 }
4023 else
4024 {
4025 254 it = select_dropitem(12);
4026 254 thedropset = 12;
4027 }
4028
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 96 times.
285 if(it!=-1)
4029 {
4030
4/8
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
96 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4031 96 itm->from_dropset = thedropset;
4032 96 items.add(itm);
4033 96 }
4034 285 }
4035
4036 285 putcombo(scrollbuf,bx - viewport.x,by - viewport.y,rpos_handle.data(),rpos_handle.cset());
4037
4038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(get_qr(qr_MORESOUNDS))
4039 {
4040
5/6
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✓ Branch 5 taken 34 times.
285 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4041 {
4042
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (combobuf[cid].usrflags&cflag3)
4043 {
4044 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4045 }
4046 34 }
4047 else
4048 {
4049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if (combobuf[cid].usrflags&cflag3)
4050 {
4051 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4052 }
4053 251 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4054 }
4055 285 }
4056
4057 285 spawn_decoration_xy(combobuf[cid], fx, fy, bx+8, by+8);
4058 4047128 }
4059
4060 1878466 void HeroClass::check_slash_block(int32_t bx, int32_t by)
4061 {
4062 //first things first
4063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1878466 times.
1878466 if(attack!=wSword)
4064 return;
4065
4066 // keep things inside the screen boundaries
4067 1878466 bx=vbound(bx, 0, world_w-1);
4068 1878466 by=vbound(by, 0, world_h-1);
4069 1878466 int32_t fx=bx;
4070 1878466 int32_t fy=by;
4071
4072
5/6
✓ Branch 0 taken 1878322 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 1878322 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9720 times.
✓ Branch 5 taken 210190 times.
2098376 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
4073
4/4
✓ Branch 0 taken 1793030 times.
✓ Branch 1 taken 85292 times.
✓ Branch 2 taken 219910 times.
✓ Branch 3 taken 1573120 times.
1878322 || (attackclk>SWORDTAPFRAME && tapping))
4074 95156 return;
4075
4076 // find out which combo row/column the coordinates are in
4077 1783310 bx = TRUNCATE_TILE(bx);
4078 1783310 by = TRUNCATE_TILE(by);
4079
4080 1783310 int cid = MAPCOMBO(bx,by);
4081 1783310 int cid_ff = MAPFFCOMBO(fx,fy);
4082 1783310 auto current_ffc_handle = getFFCAt(fx,fy);
4083 1783310 newcombo const& cmb = combobuf[cid];
4084 1783310 newcombo const& cmb_ff = combobuf[cid_ff];
4085 1783310 int type = cmb.type;
4086 1783310 int type2 = cmb_ff.type;
4087 1783310 int flag = MAPFLAG(bx,by);
4088 1783310 int flag2 = cmb.flag;
4089 1783310 int flag3 = cmb_ff.flag;
4090
4091 1783310 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
4092 1783310 int32_t i = rpos_handle.pos;
4093
4094 1783310 bool ignorescreen=false;
4095 1783310 bool ignoreffc=false;
4096
4097
2/2
✓ Branch 0 taken 1757670 times.
✓ Branch 1 taken 25640 times.
1783310 if(get_bit(screengrid, i) != 0)
4098 {
4099 25640 ignorescreen = true;
4100 25640 }
4101
2/2
✓ Branch 0 taken 1757665 times.
✓ Branch 1 taken 5 times.
1757670 else if(cmb.only_gentrig)
4102 5 ignorescreen = true;
4103
4104
4105
3/4
✓ Branch 0 taken 13170 times.
✓ Branch 1 taken 1770140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13170 times.
1783310 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
4106 {
4107 1770140 ignoreffc = true;
4108 1770140 }
4109
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 13151 times.
13170 else if(cmb_ff.only_gentrig)
4110 19 ignoreffc = true;
4111
4112
4/4
✓ Branch 0 taken 1765500 times.
✓ Branch 1 taken 17810 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1765083 times.
3548439 if(!isCuttableType(type) &&
4113
6/6
✓ Branch 0 taken 3970 times.
✓ Branch 1 taken 1761530 times.
✓ Branch 2 taken 1765129 times.
✓ Branch 3 taken 371 times.
✓ Branch 4 taken 4698 times.
✓ Branch 5 taken 1760431 times.
1765500 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4114 {
4115 1765083 ignorescreen = true;
4116 1765083 }
4117
4118
4/4
✓ Branch 0 taken 1783291 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1783290 times.
3566601 if(!isCuttableType(type2) &&
4119
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1783290 times.
1783291 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4120 {
4121 1783290 ignoreffc = true;
4122 1783290 }
4123
4124
2/2
✓ Branch 0 taken 10822 times.
✓ Branch 1 taken 1772488 times.
1783310 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
4125
4126
4/4
✓ Branch 0 taken 80438 times.
✓ Branch 1 taken 1702872 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 80382 times.
1783310 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4127 1783310 byte skipsecrets = 0;
4128
4129
2/2
✓ Branch 0 taken 1776673 times.
✓ Branch 1 taken 6637 times.
1783310 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4130 {
4131
2/2
✓ Branch 0 taken 5639 times.
✓ Branch 1 taken 998 times.
6637 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4132 {
4133 5639 skipsecrets = 0;
4134 5639 }
4135 998 else skipsecrets = 1;
4136 6637 }
4137
4138
6/6
✓ Branch 0 taken 16644 times.
✓ Branch 1 taken 1766666 times.
✓ Branch 2 taken 993 times.
✓ Branch 3 taken 15651 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 1037 times.
1783310 if(!ignorescreen && (!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
4139 {
4140
6/6
✓ Branch 0 taken 1958 times.
✓ Branch 1 taken 14730 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 432 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 1496 times.
16688 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
4141 {
4142 1496 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4143 1496 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4144 1496 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4145 1496 }
4146
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15188 times.
15192 else if(flag == mfARMOS_SECRET)
4147 {
4148 4 s->data[i] = s->secretcombo[sSTAIRS];
4149 4 s->cset[i] = s->secretcset[sSTAIRS];
4150 4 s->sflag[i] = s->secretflag[sSTAIRS];
4151 4 sfx(s->secretsfx);
4152 4 }
4153
4/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 14792 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 14770 times.
15188 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4154 {
4155
4/4
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 864 times.
✓ Branch 3 taken 374 times.
1282 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4156 {
4157 864 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4158 864 }
4159
4160 374 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4161 374 }
4162
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14758 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
14770 else if(((flag2 >= 16)&&(flag2 <= 31)))
4163 {
4164 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4165 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4166 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4167 }
4168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14770 times.
14770 else if(flag2 == mfARMOS_SECRET)
4169 {
4170 s->data[i] = s->secretcombo[sSTAIRS];
4171 s->cset[i] = s->secretcset[sSTAIRS];
4172 s->sflag[i] = s->secretflag[sSTAIRS];
4173 sfx(s->secretsfx);
4174 }
4175
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14758 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14758 times.
14770 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4176 {
4177
3/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 12 times.
32 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4178 {
4179 20 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4180 20 }
4181
4182 12 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4183 12 }
4184 else
4185 {
4186
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 9679 times.
14758 if(isCuttableNextType(type))
4187 {
4188 5079 s->data[i]++;
4189 5079 }
4190 else
4191 {
4192 9679 s->data[i] = s->undercombo;
4193 9679 s->cset[i] = s->undercset;
4194 9679 s->sflag[i] = 0;
4195 }
4196
4197 //pausenow=true;
4198 }
4199 16644 }
4200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1766710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1766710 else if(!ignorescreen && skipsecrets)
4201 {
4202 if(isCuttableNextType(type))
4203 {
4204 s->data[i]++;
4205 }
4206 else
4207 {
4208 s->data[i] = s->undercombo;
4209 s->cset[i] = s->undercset;
4210 s->sflag[i] = 0;
4211 }
4212 }
4213
4214
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1783353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1783353 times.
1783354 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4215 {
4216
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4217 {
4218 4 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4219 4 }
4220
4221 1 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
4222 1 }
4223
1/2
✓ Branch 0 taken 1783353 times.
✗ Branch 1 not taken.
1783353 else if(!ignoreffc)
4224 {
4225 if(isCuttableNextType(type2))
4226 {
4227 current_ffc_handle->increment_data();
4228 }
4229 else
4230 {
4231 current_ffc_handle->set_data(s->undercombo);
4232 current_ffc_handle->ffc->cset = s->undercset;
4233 }
4234 }
4235
4236
2/2
✓ Branch 0 taken 1766710 times.
✓ Branch 1 taken 16644 times.
1783354 if(!ignorescreen)
4237 {
4238
4/4
✓ Branch 0 taken 5436 times.
✓ Branch 1 taken 11208 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 5146 times.
16644 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4239
4240
8/8
✓ Branch 0 taken 16339 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 16384 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 45 times.
✓ Branch 7 taken 215 times.
16644 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4241 {
4242
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4243 260 sfx(s->secretsfx);
4244 260 }
4245
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 15961 times.
16384 else if(isCuttableItemType(type))
4246 {
4247 15961 int32_t it = -1;
4248 15961 int32_t thedropset = -1;
4249
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 15913 times.
15961 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4250 {
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if ( cmb.usrflags&cflag11 )
4252 {
4253 it = cmb.attribytes[1];
4254 }
4255 else
4256 {
4257 48 it = select_dropitem(cmb.attribytes[1]);
4258 48 thedropset = cmb.attribytes[1];
4259 }
4260 48 }
4261 else
4262 {
4263 15913 it = select_dropitem(12);
4264 15913 thedropset = 12;
4265 }
4266
4267
2/2
✓ Branch 0 taken 11158 times.
✓ Branch 1 taken 4803 times.
15961 if(it!=-1)
4268 {
4269
4/8
✓ Branch 0 taken 4803 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4803 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4803 times.
✗ Branch 7 not taken.
4803 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4270 4803 itm->from_dropset = thedropset;
4271 4803 items.add(itm);
4272 4803 }
4273 15961 }
4274
4275 16644 putcombo(scrollbuf, bx - viewport.x, by - viewport.y, s->data[i], s->cset[i]);
4276
4277
2/2
✓ Branch 0 taken 8270 times.
✓ Branch 1 taken 8374 times.
16644 if(get_qr(qr_MORESOUNDS))
4278 {
4279
6/6
✓ Branch 0 taken 6788 times.
✓ Branch 1 taken 1586 times.
✓ Branch 2 taken 4743 times.
✓ Branch 3 taken 2045 times.
✓ Branch 4 taken 4115 times.
✓ Branch 5 taken 628 times.
8374 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4280 {
4281
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 44 times.
628 if (cmb.usrflags&cflag3)
4282 {
4283 44 sfx(cmb.attribytes[2],int32_t(bx));
4284 44 }
4285 628 }
4286 else
4287 {
4288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7746 times.
7746 if (cmb.usrflags&cflag3)
4289 {
4290 sfx(cmb.attribytes[2],int32_t(bx));
4291 }
4292 7746 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4293 }
4294 8374 }
4295
4296 16644 spawn_decoration_xy(cmb, fx, fy, bx+8, by+8);
4297 16644 }
4298
4299
2/2
✓ Branch 0 taken 1783353 times.
✓ Branch 1 taken 1 times.
1783354 if(!ignoreffc)
4300 {
4301
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
4302 {
4303 1 current_ffc_handle->ffc->recently_hit = true;
4304 1 }
4305
4306
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(isCuttableItemType(type2))
4307 {
4308 int32_t it=-1;
4309 int32_t thedropset=-1;
4310 if ( (cmb_ff.usrflags&cflag2) )
4311 {
4312 if(cmb_ff.usrflags&cflag11)
4313 it = cmb_ff.attribytes[1];
4314 else
4315 {
4316 it = select_dropitem(cmb_ff.attribytes[1]);
4317 thedropset = cmb_ff.attribytes[1];
4318 }
4319 }
4320 else
4321 {
4322 if(get_qr(qr_HARDCODED_FFC_BUSH_DROPS))
4323 {
4324 int32_t r=zc_oldrand()%100;
4325
4326 if(r<15)
4327 it=iHeart; // 15%
4328 else if(r<35)
4329 it=iRupy; // 20%
4330 }
4331 else
4332 {
4333 it = select_dropitem(12);
4334 thedropset = 12;
4335 }
4336 }
4337
4338 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4339 {
4340 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4341 itm->from_dropset = thedropset;
4342 items.add(itm);
4343 }
4344 }
4345
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_qr(qr_MORESOUNDS))
4347 {
4348
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4349 {
4350
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (cmb_ff.usrflags&cflag3)
4351 {
4352 sfx(cmb_ff.attribytes[2],int32_t(bx));
4353 }
4354 1 }
4355 else
4356 {
4357 if (cmb_ff.usrflags&cflag3)
4358 {
4359 sfx(cmb_ff.attribytes[2],int32_t(bx));
4360 }
4361 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4362 }
4363 1 }
4364
4365 1 auto& ffc = *current_ffc_handle->ffc;
4366 1 spawn_decoration_xy(cmb_ff, fx, fy, ffc.x+(ffc.hit_width / 2), ffc.y+(ffc.hit_height / 2));
4367 1 }
4368 1878510 }
4369
4370 25566117 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4371 {
4372 25566117 bx=vbound(bx, 0, world_w-1);
4373 25566117 by=vbound(by, 0, world_h-1);
4374
5/30
✓ Branch 0 taken 3120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 648 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 201384 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 25356301 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4664 times.
✗ Branch 29 not taken.
25566117 switch(w->useweapon)
4375 {
4376 case wArrow:
4377 3120 trigger_secrets_if_flag(bx,by,mfARROW,true);
4378 3120 trigger_secrets_if_flag(bx,by,mfSARROW,true);
4379 3120 trigger_secrets_if_flag(bx,by,mfGARROW,true);
4380 3120 break;
4381 case wBeam:
4382 for(int32_t i = 0; i <4; i++) trigger_secrets_if_flag(bx,by,mfSWORDBEAM+i,true);
4383 break;
4384 case wHookshot:
4385 trigger_secrets_if_flag(bx,by,mfHOOKSHOT,true);
4386 break;
4387 case wBrang:
4388 for(int32_t i = 0; i <3; i++) trigger_secrets_if_flag(bx,by,mfBRANG+i,true);
4389 break;
4390 case wMagic:
4391 trigger_secrets_if_flag(bx,by,mfWANDMAGIC,true);
4392 break;
4393 case wRefMagic:
4394 trigger_secrets_if_flag(bx,by,mfWANDMAGIC,true);
4395 break;
4396 case wRefBeam:
4397 for(int32_t i = 0; i <4; i++) trigger_secrets_if_flag(bx,by,mfSWORDBEAM+i,true);
4398 break;
4399 //reflected magic needs to happen in mirrors:
4400 //
4401 //trigger_secrets_if_flag(bx,by,mfREFMAGIC,true)
4402 case wRefFireball:
4403 trigger_secrets_if_flag(bx,by,mfREFFIREBALL,true);
4404 break;
4405 case wBomb:
4406 648 trigger_secrets_if_flag(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4407 648 break;
4408
4409 case wSBomb:
4410 trigger_secrets_if_flag(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4411 break;
4412
4413 case wFire:
4414 201384 trigger_secrets_if_flag(bx,by,mfANYFIRE,true);
4415 201384 trigger_secrets_if_flag(bx,by,mfSTRONGFIRE,true);
4416 201384 trigger_secrets_if_flag(bx,by,mfMAGICFIRE,true);
4417 201384 break;
4418
4419 case wScript1:
4420 break;
4421 case wScript2:
4422 break;
4423 case wScript3:
4424 break;
4425 case wScript4:
4426 break;
4427 case wScript5:
4428 break;
4429 case wScript6:
4430 break;
4431 case wScript7:
4432 break;
4433 case wScript8:
4434 break;
4435 case wScript9:
4436 break;
4437 case wScript10:
4438 break;
4439 case wIce:
4440 break;
4441 case wCByrna:
4442 break;
4443 case wWhistle:
4444 break;
4445 case wSSparkle:
4446 case wFSparkle:
4447 break;
4448 case wWind:
4449 break;
4450 case wBait:
4451 break;
4452 case wFlame:
4453 case wThrown:
4454 case wBombos:
4455 case wEther:
4456 case wQuake:
4457 case wSwordLA:
4458 case wSword180:
4459 case wStomp:
4460 break;
4461 case wSword:
4462 case wWand:
4463 //case wCandle:
4464 case wHSHandle:
4465 case wLitBomb:
4466 case wLitSBomb:
4467 4664 break;
4468 25356301 default: break;
4469
4470 }
4471 25566117 }
4472
4473 51132234 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4474 {
4475
2/2
✓ Branch 0 taken 2128078 times.
✓ Branch 1 taken 49004156 times.
51132234 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4476 {
4477 49004156 return;
4478 }
4479 //keep things inside the screen boundaries
4480 2128078 bx=vbound(bx, 0, world_w-1);
4481 2128078 by=vbound(by, 0, world_h-1);
4482 2128078 int32_t fx=bx;
4483 2128078 int32_t fy=by;
4484 //first things first
4485
2/2
✓ Branch 0 taken 2121246 times.
✓ Branch 1 taken 6832 times.
2128078 if(w->useweapon != wSword)
4486 2121246 return;
4487
4488 //find out which combo row/column the coordinates are in
4489 6832 bx = TRUNCATE_TILE(bx);
4490 6832 by = TRUNCATE_TILE(by);
4491
4492
4493 6832 int32_t flag = MAPFLAGL(layer,bx,by);
4494 6832 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4495 6832 int32_t cid = MAPCOMBOL(layer,bx,by);
4496 6832 int32_t type = combobuf[cid].type;
4497
1/2
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
6832 if(combobuf[cid].only_gentrig)
4498 type = cNONE;
4499
4500 6832 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, layer);
4501 6832 int32_t i = rpos_handle.pos;
4502
4503 // bool checked = w->rposes_checked.contains({rpos_handle.layer, rpos_handle.rpos});
4504
3/4
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6826 times.
✓ Branch 3 taken 6 times.
6832 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4505 {
4506 6826 return;
4507 }
4508
4509 6 mapscr* s = rpos_handle.scr;
4510
4511
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4512
4513 {
4514
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(isCuttableNextType(type) || isCuttableNextType(type))
4516 {
4517 6 s->data[i]++;
4518 6 }
4519 else
4520 {
4521 s->data[i] = s->undercombo;
4522 s->cset[i] = s->undercset;
4523 s->sflag[i] = 0;
4524 }
4525
2/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4526 {
4527 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4528 sfx(s->secretsfx);
4529 }
4530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(isCuttableItemType(type))
4531 {
4532 6 int32_t it = -1;
4533 6 int32_t thedropset = -1;
4534
4535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( (combobuf[cid].usrflags&cflag2) )
4536 {
4537 if(combobuf[cid].usrflags&cflag11)
4538 it = combobuf[cid].attribytes[1];
4539 else
4540 {
4541 it = select_dropitem(combobuf[cid].attribytes[1]);
4542 thedropset = combobuf[cid].attribytes[1];
4543 }
4544 }
4545 else
4546 {
4547 6 it = select_dropitem(12);
4548 6 thedropset = 12;
4549 }
4550
4551
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if(it!=-1)
4552 {
4553
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4554 2 itm->from_dropset = thedropset;
4555 2 items.add(itm);
4556 2 }
4557 6 }
4558
4559 6 putcombo(scrollbuf,bx - viewport.x, by - viewport.y,rpos_handle.data(),rpos_handle.cset());
4560
4561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_qr(qr_MORESOUNDS))
4562 {
4563
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4564 {
4565 if (combobuf[cid].usrflags&cflag3)
4566 {
4567 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4568 }
4569 }
4570 else
4571 {
4572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (combobuf[cid].usrflags&cflag3)
4573 {
4574 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4575 }
4576 6 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4577 }
4578 6 }
4579
4580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4581
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(decotype > 3) decotype = 0;
4582
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4583
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 switch(decotype)
4584 {
4585 case -2: break; //nothing
4586 case -1:
4587 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4588 break;
4589
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4590 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4591 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4592 }
4593
4594 }
4595
4596 51132234 }
4597
4598 25566227 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4599 {
4600 //keep things inside the screen boundaries
4601 25566227 bx=vbound(bx, 0, world_w-1);
4602 25566227 by=vbound(by, 0, world_h-1);
4603 25566227 int32_t fx=bx;
4604 25566227 int32_t fy=by;
4605 25566227 int32_t cid = MAPCOMBO(bx,by);
4606
4607 //find out which combo row/column the coordinates are in
4608 25566227 bx = TRUNCATE_TILE(bx);
4609 25566227 by = TRUNCATE_TILE(by);
4610
4611 25566227 int32_t type = COMBOTYPE(bx,by);
4612 25566227 int32_t type2 = FFCOMBOTYPE(fx,fy);
4613 25566227 int32_t flag = MAPFLAG(bx,by);
4614 25566227 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4615 25566227 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4616
2/2
✓ Branch 0 taken 25566013 times.
✓ Branch 1 taken 214 times.
25566227 if(combobuf[cid].only_gentrig)
4617 214 type = cNONE;
4618 25566227 byte dontignore = 0;
4619 25566227 byte dontignoreffc = 0;
4620
4621
4/4
✓ Branch 0 taken 430486 times.
✓ Branch 1 taken 25135741 times.
✓ Branch 2 taken 429888 times.
✓ Branch 3 taken 598 times.
25566227 if (isCuttableType(type) && FindComboTriggerMatch(w, cid) > -1)
4622 {
4623 598 dontignore = 1;
4624 598 }
4625
4/4
✓ Branch 0 taken 25561453 times.
✓ Branch 1 taken 4774 times.
✓ Branch 2 taken 25560855 times.
✓ Branch 3 taken 598 times.
25566227 if(w->useweapon != wSword && !dontignore) return;
4626
4627 5372 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
4628 5372 int32_t i = rpos_handle.pos;
4629
4630
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5351 times.
5372 if (get_bit(w->wscreengrid,i)) return;
4631
4632 5351 bool ignorescreen=false;
4633 5351 bool ignoreffc=false;
4634
4635
1/2
✓ Branch 0 taken 5351 times.
✗ Branch 1 not taken.
5351 if(get_bit(w->wscreengrid, i) != 0)
4636 {
4637 ignorescreen = true; dontignore = 0;
4638 }
4639
4640 5351 auto current_ffc_handle = getFFCAt(fx,fy);
4641
4642
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 5085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
5351 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
4643 {
4644 5085 ignoreffc = true;
4645 5085 }
4646
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 else if(combobuf[current_ffc_handle->data()].only_gentrig)
4647 type2 = cNONE;
4648
3/4
✓ Branch 0 taken 4631 times.
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4631 times.
9982 if(!isCuttableType(type) &&
4649
5/6
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 4483 times.
✓ Branch 2 taken 4631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 718 times.
✓ Branch 5 taken 3913 times.
4631 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4650 {
4651 4631 ignorescreen = true;
4652 4631 }
4653
4654
3/4
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5241 times.
10592 if(!isCuttableType(type2) &&
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5241 times.
5241 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4656 {
4657 5241 ignoreffc = true;
4658 5241 }
4659
4660
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 5241 times.
5351 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
4661
4662
4/4
✓ Branch 0 taken 4851 times.
✓ Branch 1 taken 316 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 4618 times.
5351 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4663 5167 byte skipsecrets = 0;
4664
2/2
✓ Branch 0 taken 4630 times.
✓ Branch 1 taken 501 times.
5167 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4665 {
4666
2/2
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 3 times.
501 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4667 {
4668 498 skipsecrets = 0;
4669 498 }
4670 3 else skipsecrets = 1;
4671 501 }
4672
6/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5128 times.
✓ Branch 2 taken 4631 times.
✓ Branch 3 taken 4628 times.
✓ Branch 4 taken 4631 times.
✓ Branch 5 taken 5125 times.
5131 if((!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4673 {
4674
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9756 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4675 {
4676 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4677 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4678 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4679 }
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag == mfARMOS_SECRET)
4681 {
4682 s->data[i] = s->secretcombo[sSTAIRS];
4683 s->cset[i] = s->secretcset[sSTAIRS];
4684 s->sflag[i] = s->secretflag[sSTAIRS];
4685 sfx(s->secretsfx);
4686 }
4687
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4688 {
4689 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4690 {
4691 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4692 }
4693
4694 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4695 }
4696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
610 else if(((flag2 >= 16)&&(flag2 <= 31)))
4697 {
4698 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4699 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4700 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4701 }
4702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag2 == mfARMOS_SECRET)
4703 {
4704 s->data[i] = s->secretcombo[sSTAIRS];
4705 s->cset[i] = s->secretcset[sSTAIRS];
4706 s->sflag[i] = s->secretflag[sSTAIRS];
4707 sfx(s->secretsfx);
4708 }
4709
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4710 {
4711 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4712 {
4713 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4714 }
4715
4716 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4717 }
4718 else
4719 {
4720
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 109 times.
610 if(isCuttableNextType(type))
4721 {
4722 501 s->data[i]++;
4723 501 }
4724 else
4725 {
4726 109 s->data[i] = s->undercombo;
4727 109 s->cset[i] = s->undercset;
4728 109 s->sflag[i] = 0;
4729 }
4730
4731 //pausenow=true;
4732 }
4733 610 }
4734
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4631 else if(skipsecrets && (!ignorescreen || dontignore))
4735 {
4736 if(isCuttableNextType(type))
4737 {
4738 s->data[i]++;
4739 }
4740 else
4741 {
4742 s->data[i] = s->undercombo;
4743 s->cset[i] = s->undercset;
4744 s->sflag[i] = 0;
4745 }
4746 }
4747
4748
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5241 times.
5241 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4749 {
4750 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4751 {
4752 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4753 }
4754
4755 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
4756 }
4757
1/2
✓ Branch 0 taken 5241 times.
✗ Branch 1 not taken.
5241 else if(!ignoreffc)
4758 {
4759 if(isCuttableNextType(type2))
4760 {
4761 current_ffc_handle->increment_data();
4762 }
4763 else
4764 {
4765 current_ffc_handle->set_data(s->undercombo);
4766 current_ffc_handle->ffc->cset = s->undercset;
4767 }
4768 }
4769
4770
3/4
✓ Branch 0 taken 4631 times.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4631 times.
5241 if(!ignorescreen || dontignore)
4771 {
4772
3/4
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 425 times.
610 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4773
4774
2/8
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
610 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4775 {
4776 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4777 sfx(s->secretsfx);
4778 }
4779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(isCuttableItemType(type))
4780 {
4781 610 int32_t it = -1;
4782 610 int32_t thedropset = -1;
4783
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 601 times.
610 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4784 {
4785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( combobuf[cid].usrflags&cflag11 )
4786 {
4787 it = combobuf[cid].attribytes[1];
4788 }
4789 else
4790 {
4791 9 it = select_dropitem(combobuf[cid].attribytes[1]);
4792 9 thedropset = combobuf[cid].attribytes[1];
4793 }
4794 9 }
4795 else
4796 {
4797 601 it = select_dropitem(12);
4798 601 thedropset = 12;
4799 }
4800
4801
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 198 times.
610 if(it!=-1)
4802 {
4803
4/8
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 198 times.
✗ Branch 7 not taken.
198 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4804 198 itm->from_dropset = thedropset;
4805 198 items.add(itm);
4806 198 }
4807 610 }
4808
4809
4810 610 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
4811
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(get_qr(qr_MORESOUNDS))
4813 {
4814
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
610 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4815 {
4816 if (combobuf[cid].usrflags&cflag3)
4817 {
4818 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4819 }
4820 }
4821 else
4822 {
4823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (combobuf[cid].usrflags&cflag3)
4824 {
4825 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4826 }
4827 610 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4828 }
4829 610 }
4830
4831
3/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 598 times.
✗ Branch 3 not taken.
610 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4832
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(decotype > 3) decotype = 0;
4833
6/8
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
610 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4834
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 501 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 9 times.
610 switch(decotype)
4835 {
4836 case -2: break; //nothing
4837 case -1:
4838 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4839 break;
4840
3/6
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 501 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 501 times.
✗ Branch 5 not taken.
501 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4841
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4842
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4843 }
4844 610 }
4845
4846
1/2
✓ Branch 0 taken 5241 times.
✗ Branch 1 not taken.
5241 if(!ignoreffc)
4847 {
4848 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
4849 {
4850 current_ffc_handle->ffc->recently_hit = true;
4851 }
4852
4853 if(isCuttableItemType(type2))
4854 {
4855 int32_t it=-1;
4856 int32_t thedropset=-1;
4857 if ( (combobuf[cid].usrflags&cflag2) )
4858 {
4859 if(combobuf[cid].usrflags&cflag11)
4860 it = combobuf[cid].attribytes[1];
4861 else
4862 {
4863 it = select_dropitem(combobuf[cid].attribytes[1]);
4864 thedropset = combobuf[cid].attribytes[1];
4865 }
4866 }
4867 else
4868 {
4869 int32_t r=zc_oldrand()%100;
4870
4871 if(r<15)
4872 {
4873 it=iHeart; // 15%
4874 }
4875 else if(r<35)
4876 {
4877 it=iRupy; // 20%
4878 }
4879 }
4880
4881 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4882 {
4883 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4884 itm->from_dropset = thedropset;
4885 items.add(itm);
4886 }
4887 }
4888
4889 if(get_qr(qr_MORESOUNDS))
4890 {
4891 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4892 {
4893 if (combobuf[cid].usrflags&cflag3)
4894 {
4895 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4896 }
4897 }
4898 else
4899 {
4900 if (combobuf[cid].usrflags&cflag3)
4901 {
4902 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4903 }
4904 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4905 }
4906 }
4907
4908 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4909 if(decotype > 3) decotype = 0;
4910 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4911 switch(decotype)
4912 {
4913 case -2: break; //nothing
4914 case -1:
4915 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4916 break;
4917 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4918 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4919 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4920 }
4921 }
4922 25566117 }
4923
4924 25566117 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4925 {
4926 25566117 byte dontignore = 0;
4927 25566117 byte dontignoreffc = 0;
4928
4929 //keep things inside the screen boundaries
4930 25566117 bx=vbound(bx, 0, world_w-1);
4931 25566117 by=vbound(by, 0, world_h-1);
4932 25566117 int32_t fx=bx;
4933 25566117 int32_t fy=by;
4934 25566117 int32_t cid = MAPCOMBO(bx,by);
4935
4936 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4937
3/4
✓ Branch 0 taken 25566117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✓ Branch 3 taken 25563355 times.
25566117 if(w->useweapon != wWand && FindComboTriggerMatch (w, cid) < 0) return;
4938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2762 times.
2762 if ( FindComboTriggerMatch (w, cid) != -1 ) dontignore = 1;
4939
4940 //first things first
4941
2/4
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
2762 if(z>8||fakez>8) return;
4942
4943 //find out which combo row/column the coordinates are in
4944 2762 bx = TRUNCATE_TILE(bx);
4945 2762 by = TRUNCATE_TILE(by);
4946
4947 2762 int32_t flag = MAPFLAG(bx,by);
4948 2762 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4949 2762 int32_t flag3=0;
4950 2762 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4951 2762 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4952 2762 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4953 2762 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4954
4955
4/8
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2762 times.
2762 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4956 flag3=mfWAND;
4957
4958
4/8
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2762 times.
2762 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4959 flag3=mfSTRIKE;
4960
4961
6/12
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2762 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2762 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2762 times.
2762 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4962 2762 return;
4963
4964 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
4965 {
4966 if(flag3==mfWAND||flag3==mfSTRIKE)
4967 {
4968 trigger_secrets_if_flag(fx,fy,mfWAND,true);
4969 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
4970 }
4971 }
4972
4973 if(dontignore)
4974 trigger_secrets_if_flag(bx,by,mfWAND,true);
4975 25566117 }
4976
4977 void HeroClass::check_slash_block(weapon *w)
4978 {
4979 //first things
4980
4981 int32_t par_item = w->parentitem;
4982 int32_t usewpn = -1;
4983 if ( par_item > -1 )
4984 {
4985 usewpn = itemsbuf[par_item].weap_data.imitate_weapon;
4986 }
4987 else if ( par_item == -1 && w->ScriptGenerated )
4988 {
4989 usewpn = w->useweapon;
4990 }
4991 if(usewpn != wSword) return;
4992
4993
4994 int32_t bx = 0, by = 0;
4995 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
4996 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
4997 //keep things inside the screen boundaries
4998 bx=vbound(bx, 0, world_w-1);
4999 by=vbound(by, 0, world_h-1);
5000 int32_t fx=bx;
5001 int32_t fy=by;
5002
5003 int32_t cid = MAPCOMBO(bx,by);
5004
5005 //find out which combo row/column the coordinates are in
5006 bx = TRUNCATE_TILE(bx);
5007 by = TRUNCATE_TILE(by);
5008
5009 int32_t type = COMBOTYPE(bx,by);
5010 int32_t type2 = FFCOMBOTYPE(fx,fy);
5011 int32_t flag = MAPFLAG(bx,by);
5012 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5013 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5014 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
5015 int32_t i = rpos_handle.pos;
5016
5017 if(combobuf[cid].only_gentrig)
5018 type = cNONE;
5019 bool ignorescreen=false;
5020 bool ignoreffc=false;
5021
5022 if(get_bit(screengrid, i) != 0)
5023 {
5024 ignorescreen = true;
5025 }
5026
5027 auto current_ffc_handle = getFFCAt(fx,fy);
5028
5029 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
5030 {
5031 ignoreffc = true;
5032 }
5033 else if(combobuf[current_ffc_handle->data()].only_gentrig)
5034 type2 = cNONE;
5035 if(!isCuttableType(type) &&
5036 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5037 {
5038 ignorescreen = true;
5039 }
5040
5041 if(!isCuttableType(type2) &&
5042 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5043 {
5044 ignoreffc = true;
5045 }
5046
5047 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
5048
5049 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5050
5051 if(!ignorescreen)
5052 {
5053 if((flag >= 16)&&(flag <= 31))
5054 {
5055 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5056 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5057 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5058 }
5059 else if(flag == mfARMOS_SECRET)
5060 {
5061 s->data[i] = s->secretcombo[sSTAIRS];
5062 s->cset[i] = s->secretcset[sSTAIRS];
5063 s->sflag[i] = s->secretflag[sSTAIRS];
5064 sfx(s->secretsfx);
5065 }
5066 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5067 {
5068 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5069 {
5070 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5071 }
5072
5073 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5074 }
5075 else if(((flag2 >= 16)&&(flag2 <= 31)))
5076 {
5077 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5078 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5079 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5080 }
5081 else if(flag2 == mfARMOS_SECRET)
5082 {
5083 s->data[i] = s->secretcombo[sSTAIRS];
5084 s->cset[i] = s->secretcset[sSTAIRS];
5085 s->sflag[i] = s->secretflag[sSTAIRS];
5086 sfx(s->secretsfx);
5087 }
5088 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5089 {
5090 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5091 {
5092 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5093 }
5094
5095 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5096 }
5097 else
5098 {
5099 if(isCuttableNextType(type))
5100 {
5101 s->data[i]++;
5102 }
5103 else
5104 {
5105 s->data[i] = s->undercombo;
5106 s->cset[i] = s->undercset;
5107 s->sflag[i] = 0;
5108 }
5109
5110 //pausenow=true;
5111 }
5112 }
5113
5114 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5115 {
5116 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5117 {
5118 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5119 }
5120
5121 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5122 }
5123 else if(!ignoreffc)
5124 {
5125 if(isCuttableNextType(type2))
5126 {
5127 current_ffc_handle->increment_data();
5128 }
5129 else
5130 {
5131 current_ffc_handle->set_data(s->undercombo);
5132 current_ffc_handle->set_cset(s->undercset);
5133 }
5134 }
5135
5136 if(!ignorescreen)
5137 {
5138 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5139
5140 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5141 {
5142 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5143 sfx(s->secretsfx);
5144 }
5145 else if(isCuttableItemType(type))
5146 {
5147 int32_t it = -1;
5148 int32_t thedropset = -1;
5149 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5150 {
5151 if ( combobuf[cid].usrflags&cflag11 )
5152 {
5153 it = combobuf[cid].attribytes[1];
5154 }
5155 else
5156 {
5157 it = select_dropitem(combobuf[cid].attribytes[1]);
5158 thedropset = combobuf[cid].attribytes[1];
5159 }
5160 }
5161 else
5162 {
5163 it = select_dropitem(12);
5164 thedropset = 12;
5165 }
5166
5167 if(it!=-1)
5168 {
5169 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5170 itm->from_dropset = thedropset;
5171 items.add(itm);
5172 }
5173 }
5174
5175 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
5176
5177 if(get_qr(qr_MORESOUNDS))
5178 {
5179 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5180 {
5181 if (combobuf[cid].usrflags&cflag3)
5182 {
5183 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5184 }
5185 }
5186 else
5187 {
5188 if (combobuf[cid].usrflags&cflag3)
5189 {
5190 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5191 }
5192 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5193 }
5194 }
5195
5196 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5197 if(decotype > 3) decotype = 0;
5198 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5199 switch(decotype)
5200 {
5201 case -2: break; //nothing
5202 case -1:
5203 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5204 break;
5205 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5206 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5207 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5208 }
5209 }
5210
5211 if(!ignoreffc)
5212 {
5213 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
5214 {
5215 current_ffc_handle->ffc->recently_hit = true;
5216 }
5217
5218 if(isCuttableItemType(type2))
5219 {
5220 int32_t it=-1;
5221 int32_t thedropset = -1;
5222 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5223 {
5224 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5225 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5226 else
5227 {
5228 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5229 it = select_dropitem(thedropset);
5230 }
5231 }
5232 else
5233 {
5234 it = select_dropitem(12);
5235 thedropset = 12;
5236 }
5237
5238 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5239 {
5240 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5241 itm->from_dropset = thedropset;
5242 items.add(itm);
5243 }
5244 }
5245
5246 if(get_qr(qr_MORESOUNDS))
5247 {
5248 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5249 {
5250 if (combobuf[cid].usrflags&cflag3)
5251 {
5252 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5253 }
5254 }
5255 else
5256 {
5257 if (combobuf[cid].usrflags&cflag3)
5258 {
5259 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5260 }
5261 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5262 }
5263 }
5264
5265 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5266 if(decotype > 3) decotype = 0;
5267 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5268 switch(decotype)
5269 {
5270 case -2: break; //nothing
5271 case -1:
5272 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5273 break;
5274 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5275 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5276 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5277 }
5278 }
5279 }
5280
5281 38240 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5282 {
5283 //keep things inside the screen boundaries
5284 38240 bx=vbound(bx, 0, world_w-1);
5285 38240 by=vbound(by, 0, world_h-1);
5286 38240 int32_t fx=bx;
5287 38240 int32_t fy=by;
5288
5289 //first things first
5290
2/4
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
38240 if(z>8||fakez>8) return;
5291
5292 //find out which combo row/column the coordinates are in
5293 38240 bx = TRUNCATE_TILE(bx);
5294 38240 by = TRUNCATE_TILE(by);
5295
5296 38240 int32_t flag = MAPFLAG(bx,by);
5297 38240 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5298 38240 int32_t flag3=0;
5299 38240 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5300 38240 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5301 38240 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5302 38240 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5303
5304
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5305 flag3=mfWAND;
5306
5307
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5308 flag3=mfSTRIKE;
5309
5310
7/12
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38239 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 38239 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38239 times.
✗ Branch 11 not taken.
38240 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5311 38239 return;
5312
5313
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
5314 {
5315 if(flag3==mfWAND||flag3==mfSTRIKE)
5316 {
5317 trigger_secrets_if_flag(fx,fy,mfWAND,true);
5318 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5319 }
5320 }
5321 38240 }
5322
5323 5124 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5324 {
5325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5124 if(w && w->no_triggers()) return;
5326
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5124 if(w && w->id == wHammer && getHammerState() < 3)
5327 return;
5328
1/2
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
5124 if(get_qr(qr_POUNDLAYERS1AND2))
5329 {
5330 check_pound_block_layer(bx,by,1,w);
5331 check_pound_block_layer(bx,by,2,w);
5332 }
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 auto* grid = w ? w->wscreengrid : screengrid;
5334 //keep things inside the screen boundaries
5335 5124 bx=vbound(bx, 0, world_w-1);
5336 5124 by=vbound(by, 0, world_h-1);
5337 5124 int32_t fx=bx;
5338 5124 int32_t fy=by;
5339
5340 //first things first
5341
2/4
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5124 times.
5124 if(z>8||fakez>8) return;
5342
5343 //find out which combo row/column the coordinates are in
5344 5124 bx = TRUNCATE_TILE(bx);
5345 5124 by = TRUNCATE_TILE(by);
5346
5347 5124 int32_t type = COMBOTYPE(bx,by);
5348 5124 int32_t type2 = FFCOMBOTYPE(fx,fy);
5349 5124 int32_t flag = MAPFLAG(bx,by);
5350 5124 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5351 5124 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5352
5353 5124 rpos_t rpos = COMBOPOS_REGION(bx, by);
5354 5124 int32_t pos = RPOS_TO_POS(rpos);
5355
1/2
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
5124 if (!is_valid_rpos(rpos))
5356 return;
5357
5358 5124 bool ignorescreen=false;
5359 5124 bool ignoreffc=false;
5360 5124 bool pound=false;
5361
5362
9/10
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 4430 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4430 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4428 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 4426 times.
5124 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5363 4426 ignorescreen = true; // Affect only FFCs
5364
5365
2/2
✓ Branch 0 taken 4668 times.
✓ Branch 1 taken 456 times.
5124 if(get_bit(grid, pos) != 0)
5366 456 ignorescreen = true;
5367
5368 5124 auto current_ffc_handle = getFFCAt(fx,fy);
5369
5370
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 5084 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
5124 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
5371 5084 ignoreffc = true;
5372
5373
3/6
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5124 times.
5124 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5374 5124 ignoreffc = true;
5375
5376
3/4
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4597 times.
5124 if(ignorescreen && ignoreffc) // Nothing to do.
5377 4597 return;
5378
5379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : get_scr_for_world_xy(bx, by);
5380
5381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5382 {
5383
3/4
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 499 times.
527 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5384 {
5385 28 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5386 28 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5387 28 }
5388
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
499 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5389 {
5390 2 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5391 2 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5392 2 }
5393
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
497 else if((flag >= 16)&&(flag <= 31))
5394 {
5395 5 s->data[pos] = s->secretcombo[(s->sflag[pos])-16+4];
5396 5 s->cset[pos] = s->secretcset[(s->sflag[pos])-16+4];
5397 5 s->sflag[pos] = s->secretflag[(s->sflag[pos])-16+4];
5398 5 }
5399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag == mfARMOS_SECRET)
5400 {
5401 s->data[pos] = s->secretcombo[sSTAIRS];
5402 s->cset[pos] = s->secretcset[sSTAIRS];
5403 s->sflag[pos] = s->secretflag[sSTAIRS];
5404 sfx(s->secretsfx);
5405 }
5406
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
492 else if((flag2 >= 16)&&(flag2 <= 31))
5407 {
5408 s->data[pos] = s->secretcombo[(s->sflag[pos])-16+4];
5409 s->cset[pos] = s->secretcset[(s->sflag[pos])-16+4];
5410 s->sflag[pos] = s->secretflag[(s->sflag[pos])-16+4];
5411 }
5412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag2 == mfARMOS_SECRET)
5413 {
5414 s->data[pos] = s->secretcombo[sSTAIRS];
5415 s->cset[pos] = s->secretcset[sSTAIRS];
5416 s->sflag[pos] = s->secretflag[sSTAIRS];
5417 sfx(s->secretsfx);
5418 }
5419 492 else pound = true;
5420 527 }
5421
5422
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5423 {
5424 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5425 {
5426 trigger_secrets_if_flag(fx,fy,mfHAMMER,true);
5427 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5428 }
5429 else
5430 {
5431 current_ffc_handle->increment_data();
5432 }
5433 }
5434
5435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5436 {
5437
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 492 times.
527 if(pound)
5438 492 s->data[pos]+=1;
5439
5440 527 set_bit(grid,pos,1);
5441
5442 527 set_bit(screengrid,pos,1);
5443
5444
5/8
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 523 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
527 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5445 {
5446
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item((zfix)bx, (zfix)by, (zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5447 4 sfx(s->secretsfx);
5448 4 }
5449
5450
4/4
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 311 times.
527 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5451 311 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5452
5453 527 putcombo(scrollbuf, bx - viewport.x, by - viewport.y, s->data[pos], s->cset[pos]);
5454 527 }
5455
5456
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5457 {
5458 current_ffc_handle->ffc->recently_hit = true;
5459
5460 if(type2==cPOUND && get_qr(qr_MORESOUNDS))
5461 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5462 }
5463
5464 527 return;
5465 5124 }
5466
5467 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5468 {
5469 if(lyr < 1 || lyr > 2) return; //sanity
5470 //keep things inside the screen boundaries
5471 bx=vbound(bx, 0, world_w-1);
5472 by=vbound(by, 0, world_h-1);
5473 int32_t cid = MAPCOMBOL(lyr,bx,by);
5474 newcombo const& scr_cmb = combobuf[cid];
5475 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5476
5477 //first things first
5478 if(z>8||fakez>8) return;
5479
5480 //find out which combo row/column the coordinates are in
5481 bx = TRUNCATE_TILE(bx);
5482 by = TRUNCATE_TILE(by);
5483
5484 int32_t type = scr_cmb.type;
5485 int32_t flag = MAPFLAGL(lyr,bx,by);
5486 int32_t flag2 = scr_cmb.flag;
5487 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, lyr);
5488 int32_t i = rpos_handle.pos;
5489
5490 bool pound=false;
5491
5492 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5493 return;
5494
5495 if(get_bit(grid, i) != 0)
5496 return;
5497
5498 mapscr *s = rpos_handle.scr;
5499
5500 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5501 {
5502 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5503 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5504 }
5505 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5506 {
5507 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5508 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5509 }
5510 else if((flag >= 16)&&(flag <= 31))
5511 {
5512 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5513 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5514 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5515 }
5516 else if(flag == mfARMOS_SECRET)
5517 {
5518 s->data[i] = s->secretcombo[sSTAIRS];
5519 s->cset[i] = s->secretcset[sSTAIRS];
5520 s->sflag[i] = s->secretflag[sSTAIRS];
5521 sfx(s->secretsfx);
5522 }
5523 else if((flag2 >= 16)&&(flag2 <= 31))
5524 {
5525 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5526 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5527 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5528 }
5529 else if(flag2 == mfARMOS_SECRET)
5530 {
5531 s->data[i] = s->secretcombo[sSTAIRS];
5532 s->cset[i] = s->secretcset[sSTAIRS];
5533 s->sflag[i] = s->secretflag[sSTAIRS];
5534 sfx(s->secretsfx);
5535 }
5536 else pound = true;
5537
5538 if(pound)
5539 s->data[i]+=1;
5540
5541 set_bit(grid,i,1);
5542
5543 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5544 {
5545 items.add(new item((zfix)bx, (zfix)by, (zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5546 sfx(s->secretsfx);
5547 }
5548
5549 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5550 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5551
5552
5553 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
5554 }
5555
5556 void HeroClass::check_wand_block(weapon *w)
5557 {
5558
5559 int32_t par_item = w->parentitem;
5560 int32_t usewpn = -1;
5561 if ( par_item > -1 )
5562 {
5563 usewpn = itemsbuf[par_item].weap_data.imitate_weapon;
5564 }
5565 else if ( par_item == -1 && w->ScriptGenerated )
5566 {
5567 usewpn = w->useweapon;
5568 }
5569 if(usewpn != wWand) return;
5570
5571
5572 int32_t bx = 0, by = 0;
5573 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5574 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5575
5576 //keep things inside the screen boundaries
5577 bx=vbound(bx, 0, world_w-1);
5578 by=vbound(by, 0, world_h-1);
5579 int32_t fx=bx;
5580 int32_t fy=by;
5581 int32_t cid = MAPCOMBO(bx,by);
5582 //first things first
5583 if(z>8||fakez>8) return;
5584
5585 //find out which combo row/column the coordinates are in
5586 bx = TRUNCATE_TILE(bx);
5587 by = TRUNCATE_TILE(by);
5588
5589 int32_t flag = MAPFLAG(bx,by);
5590 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5591 int32_t flag3=0;
5592 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5593 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5594 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5595 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5596
5597 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5598 flag3=mfWAND;
5599
5600 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5601 flag3=mfSTRIKE;
5602
5603 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5604 return;
5605
5606 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
5607 {
5608 if(flag3==mfWAND||flag3==mfSTRIKE)
5609 {
5610 trigger_secrets_if_flag(fx,fy,mfWAND,true);
5611 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5612 }
5613 }
5614 }
5615
5616 //defend results should match defence types.
5617 //RETURN VALUES:
5618 // -1 iGNORE WEAPON
5619 // 0 No effects
5620 // 1 Effects, weapon is not ignored or removed
5621 11562 int32_t HeroClass::defend(weapon *w)
5622 {
5623 11562 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5624
2/25
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
11562 switch(def)
5625 {
5626 11553 case edNORMAL: return 1;
5627 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5628 {
5629 w->power *= 0.5;
5630 return 1;
5631 }
5632 case edQUARTDAMAGE:
5633 {
5634 w->power *= 0.25;
5635 return 1;
5636 }
5637 case edSTUNONLY:
5638 {
5639 setStunClock(120);
5640 return 1;
5641 }
5642 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5643 {
5644 if (w->power > 0)
5645 {
5646 setStunClock(120);
5647 return 1;
5648 }
5649 else
5650 {
5651 sfx(WAV_CHINK,pan(int32_t(x)));
5652 w->dead = 0;
5653 return -1;
5654 }
5655 }
5656 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5657 {
5658 if (w->power > 0)
5659 {
5660 setStunClock(120);
5661 return 1;
5662 }
5663 else
5664 {
5665 return -1;
5666 }
5667 }
5668 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5669 {
5670 if (w->power < 1)
5671 {
5672 sfx(WAV_CHINK,pan(int32_t(x)));
5673 w->dead = 0;
5674 return -1;
5675 }
5676 else
5677 {
5678 return 1;
5679 }
5680 }
5681 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5682 {
5683 if (w->power < 2)
5684 {
5685 sfx(WAV_CHINK,pan(int32_t(x)));
5686 w->dead = 0;
5687 return -1;
5688 }
5689 else
5690 {
5691 return 1;
5692 }
5693 }
5694 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5695 {
5696 if (w->power < 4)
5697 {
5698 sfx(WAV_CHINK,pan(int32_t(x)));
5699 w->dead = 0;
5700 return -1;
5701 }
5702 else
5703 {
5704 return 1;
5705 }
5706 }
5707 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5708 {
5709 if (w->power < 6)
5710 {
5711 sfx(WAV_CHINK,pan(int32_t(x)));
5712 w->dead = 0;
5713 return -1;
5714 }
5715 else
5716 {
5717 return 1;
5718 }
5719 }
5720 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5721 {
5722 if (w->power < 8)
5723 {
5724 sfx(WAV_CHINK,pan(int32_t(x)));
5725 w->dead = 0;
5726 return -1;
5727 }
5728 else
5729 {
5730 return 1;
5731 }
5732 }
5733 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5734 {
5735 sfx(WAV_CHINK,pan(int32_t(x)));
5736 w->dead = 0;
5737 return -1;
5738 }
5739 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5740 {
5741 if (w->power < 1)
5742 {
5743 return -1;
5744 }
5745 else return 1;
5746 }
5747 case edIGNORE: // : IMPLEMENTED : Do Nothing
5748 {
5749 return -1;
5750 }
5751 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5752 {
5753 game->set_life(0);
5754 return 1;
5755 }
5756 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5757 {
5758 if (w->power < 10)
5759 {
5760 sfx(WAV_CHINK,pan(int32_t(x)));
5761 w->dead = 0;
5762 return -1;
5763 }
5764 else
5765 {
5766 return 1;
5767 }
5768 }
5769 case ed2x: // : IMPLEMENTED : Double damage.
5770 {
5771 w->power *= 2;
5772 return 1;
5773 }
5774 case ed3x: // : IMPLEMENTED : Triple Damage.
5775 {
5776 w->power *= 3;
5777 return 1;
5778 }
5779 case ed4x: // : IMPLEMENTED : 4x damage.
5780 {
5781 w->power *= 4;
5782 return 1;
5783 }
5784 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5785 {
5786 //sfx(WAV_HEAL,pan(int32_t(x)));
5787 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5788 w->dead = 0;
5789 return -1;
5790 }
5791
5792 case edFREEZE: return 1; //Not IMPLEMENTED
5793
5794 case edLEVELDAMAGE: //Damage * item level
5795 {
5796 w->power *= w->family_level;
5797 return 1;
5798 }
5799 case edLEVELREDUCTION: //Damage / item level
5800 {
5801 if ( w->family_level > 0 )
5802 {
5803 w->power /= w->family_level;
5804 }
5805 else w->power = 0;
5806 return 1;
5807 }
5808
5809 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5810 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5811 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5812 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5813
5814 //edSHOCK, //buzz blob
5815
5816
5817 case edBREAKSHIELD: //destroy the player's present shield
5818 {
5819 w->power = 0;
5820 w->dead = 0;
5821 int32_t itemid = getCurrentShield();
5822 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5823 if(itemsbuf[itemid].flags&item_edible)
5824 game->set_item(itemid, false);
5825 //Remove Hero's shield
5826 return -1;
5827 }
5828
5829
5830
5831 9 default: return 0;
5832 }
5833 11562 }
5834 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5835 {
5836 return al_map_rgba(0,0,255,opacity);
5837 }
5838 10938 int32_t HeroClass::compareDir(int32_t other)
5839 {
5840
5/6
✓ Branch 0 taken 10921 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10921 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 10833 times.
10938 if(other != NORMAL_DIR(other))
5841 105 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5842 10833 int32_t ret = 0;
5843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10833 times.
10833 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5844
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 1854 times.
✓ Branch 3 taken 3461 times.
✓ Branch 4 taken 3377 times.
10833 switch(d)
5845 {
5846 case up:
5847 {
5848
3/3
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 784 times.
2141 switch(X_DIR(other))
5849 {
5850 case left:
5851 848 ret |= CMPDIR_RIGHT;
5852 848 break;
5853 case right:
5854 784 ret |= CMPDIR_LEFT;
5855 784 break;
5856 }
5857
3/3
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 1551 times.
2141 switch(Y_DIR(other))
5858 {
5859 case up:
5860 335 ret |= CMPDIR_BACK;
5861 335 break;
5862 case down:
5863 1551 ret |= CMPDIR_FRONT;
5864 1551 break;
5865 }
5866 2141 break;
5867 }
5868 case down:
5869 {
5870
3/3
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 709 times.
1854 switch(X_DIR(other))
5871 {
5872 case left:
5873 617 ret |= CMPDIR_LEFT;
5874 617 break;
5875 case right:
5876 709 ret |= CMPDIR_RIGHT;
5877 709 break;
5878 }
5879
3/3
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 317 times.
1854 switch(Y_DIR(other))
5880 {
5881 case up:
5882 1262 ret |= CMPDIR_FRONT;
5883 1262 break;
5884 case down:
5885 317 ret |= CMPDIR_BACK;
5886 317 break;
5887 }
5888 1854 break;
5889 }
5890 case left:
5891 {
5892
3/3
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 2768 times.
3461 switch(X_DIR(other))
5893 {
5894 case left:
5895 496 ret |= CMPDIR_BACK;
5896 496 break;
5897 case right:
5898 2768 ret |= CMPDIR_FRONT;
5899 2768 break;
5900 }
5901
3/3
✓ Branch 0 taken 1385 times.
✓ Branch 1 taken 891 times.
✓ Branch 2 taken 1185 times.
3461 switch(Y_DIR(other))
5902 {
5903 case up:
5904 891 ret |= CMPDIR_LEFT;
5905 891 break;
5906 case down:
5907 1185 ret |= CMPDIR_RIGHT;
5908 1185 break;
5909 }
5910 3461 break;
5911 }
5912 case right:
5913 {
5914
3/3
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 2705 times.
✓ Branch 2 taken 483 times.
3377 switch(X_DIR(other))
5915 {
5916 case left:
5917 2705 ret |= CMPDIR_FRONT;
5918 2705 break;
5919 case right:
5920 483 ret |= CMPDIR_BACK;
5921 483 break;
5922 }
5923
3/3
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1208 times.
3377 switch(Y_DIR(other))
5924 {
5925 case up:
5926 832 ret |= CMPDIR_RIGHT;
5927 832 break;
5928 case down:
5929 1208 ret |= CMPDIR_LEFT;
5930 1208 break;
5931 }
5932 3377 break;
5933 }
5934 }
5935 10833 return ret;
5936 10938 }
5937
5938 10938 bool compareShield(int32_t cmpdir, itemdata const& shield)
5939 {
5940
1/2
✓ Branch 0 taken 10938 times.
✗ Branch 1 not taken.
10938 bool standard = !(shield.flags&item_flag9) || usingActiveShield();
5941
1/2
✓ Branch 0 taken 10938 times.
✗ Branch 1 not taken.
10938 if(standard) //Use standard sides, either a passive shield, or a held active shield
5942 {
5943
4/4
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 2652 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 8277 times.
10938 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag1))
5944 8277 return true;
5945
3/4
✓ Branch 0 taken 1631 times.
✓ Branch 1 taken 1030 times.
✓ Branch 2 taken 1631 times.
✗ Branch 3 not taken.
2661 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag2))
5946 return true;
5947
3/4
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 1029 times.
✗ Branch 3 not taken.
2661 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag3))
5948 return true;
5949
3/4
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 1521 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1140 times.
2661 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag4))
5950 return true;
5951 2661 }
5952 else //Active Shield that is NOT held down
5953 {
5954 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag5))
5955 return true;
5956 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag6))
5957 return true;
5958 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag7))
5959 return true;
5960 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag8))
5961 return true;
5962 }
5963 2661 return false;
5964 10938 }
5965
5966 7259 static bool sh_check(uint fl_block, uint fl_ref, int wty, bool& reflect, bool boss, bool defret)
5967 {
5968 7259 reflect = false;
5969
10/20
✓ Branch 0 taken 3555 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 416 times.
✓ Branch 3 taken 988 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 510 times.
✓ Branch 6 taken 1039 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 391 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
7259 switch(wty)
5970 {
5971 case ewBrang:
5972
1/2
✓ Branch 0 taken 391 times.
✗ Branch 1 not taken.
391 if(!(fl_block & sh_brang)) break;
5973
5974 391 reflect = ((fl_ref & sh_brang) != 0);
5975 391 return true;
5976 case ewArrow:
5977 case wRefArrow:
5978
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 if(!(fl_block & sh_arrow)) break;
5979
5980 329 reflect = ((fl_ref & sh_arrow) != 0);
5981 329 return true;
5982
5983 case ewRock:
5984 case wRefRock:
5985
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 if(!(fl_block & sh_rock)) break;
5986
5987 416 reflect = ((fl_ref & sh_rock) != 0);
5988 416 return true;
5989 case ewFlame:
5990 case wRefFire:
5991
2/2
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 349 times.
988 if(!(fl_block & sh_flame)) break;
5992
5993 639 reflect = ((fl_ref & sh_flame) != 0);
5994 639 return true;
5995 case ewFlame2:
5996 case wRefFire2:
5997 if(get_qr(qr_BROKEN_FLAME_ARROW_REFLECTING))
5998 return true;
5999 if(!(fl_block & sh_flame2)) break;
6000
6001 reflect = ((fl_ref & sh_flame2) != 0);
6002 return true;
6003
6004 case ewFireball2:
6005 case ewFireball:
6006 case wRefFireball:
6007 {
6008 3555 int32_t mask = (boss ? sh_fireball2 : sh_fireball);
6009
6010
2/2
✓ Branch 0 taken 3071 times.
✓ Branch 1 taken 484 times.
3555 if(!(fl_block & mask)) break;
6011
6012 3071 reflect = ((fl_ref & mask) != 0);
6013 3071 return true;
6014 }
6015
6016 case ewSword:
6017 case wRefBeam:
6018
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 91 times.
510 if(!(fl_block & sh_sword)) break;
6019
6020 419 reflect = ((fl_ref & sh_sword) != 0);
6021 419 return true;
6022
6023 case wRefMagic:
6024 case ewMagic:
6025
2/2
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 70 times.
1039 if(!(fl_block & sh_magic)) break;
6026
6027 969 reflect = ((fl_ref & sh_magic) != 0);
6028 969 return true;
6029
6030 #define SCRIPT_SHBLOCK(scrfl) \
6031 if(!(fl_block & (sh_script|scrfl))) break; \
6032 reflect = ((fl_ref & (sh_script|scrfl)) != 0); \
6033 return true
6034
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 case wScript1: SCRIPT_SHBLOCK(sh_script1);
6035 case wScript2: SCRIPT_SHBLOCK(sh_script2);
6036 case wScript3: SCRIPT_SHBLOCK(sh_script3);
6037 case wScript4: SCRIPT_SHBLOCK(sh_script4);
6038 case wScript5: SCRIPT_SHBLOCK(sh_script5);
6039 case wScript6: SCRIPT_SHBLOCK(sh_script6);
6040 case wScript7: SCRIPT_SHBLOCK(sh_script7);
6041 case wScript8: SCRIPT_SHBLOCK(sh_script8);
6042 case wScript9: SCRIPT_SHBLOCK(sh_script9);
6043 case wScript10: SCRIPT_SHBLOCK(sh_script10);
6044 #undef SCRIPT_SHBLOCK
6045
6046 case ewLitBomb:
6047 case ewLitSBomb:
6048 2 return true;
6049
6050 default:
6051 20 return defret;
6052 }
6053 1003 return false;
6054 7259 }
6055
6056 bool HeroClass::check_ewpn_collide(weapon* w)
6057 {
6058 if(w->ignoreHero || w->fallclk|| w->drownclk)
6059 return false;
6060 if(!w->hit(x+7,y+7-fakez,z,2,2,1))
6061 return false;
6062
6063 int32_t stompid = current_item_id(itype_stompboots);
6064
6065 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6066 ((z+fakez) > (w->z+(w->fakez))) ||
6067 ((isSideViewHero() && (y+16)-(w->y)<=14) && falling_oldy<y)))
6068 {
6069 itemdata const& stomp = itemsbuf[stompid];
6070 bool reflect = false; //unused, always false
6071 if(!sh_check(stomp.misc2, 0, w->id, reflect, w->type&1, true))
6072 {
6073 w->onhit(false);
6074 sfx(WAV_CHINK,pan(x.getInt()));
6075 return false;
6076 }
6077 }
6078
6079 int32_t defresult = defend(w);
6080 if ( defresult == -1 ) return false; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6081
6082 if(w->id==ewWind)
6083 {
6084 xofs=1000;
6085 action=freeze; FFCore.setHeroAction(freeze);
6086 w->misc=999; // in enemy wind
6087 attackclk=0;
6088 return false;
6089 }
6090
6091 switch(w->id)
6092 {
6093 case ewLitBomb:
6094 case ewBomb:
6095 case ewLitSBomb:
6096 case ewSBomb:
6097 return true;
6098 }
6099
6100 int32_t itemid = getCurrentShield(false);
6101 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6102 return true;
6103 itemdata const& shield = itemsbuf[itemid];
6104 bool allow_inactive = (shield.flags & item_flag9);
6105 auto cmpdir = compareDir(w->dir);
6106 bool hitshield = compareShield(cmpdir, shield);
6107
6108 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6109 return true;
6110
6111 if(!hitshield)
6112 return true;
6113
6114 paymagiccost(itemid);
6115
6116 bool reflect = false;
6117
6118 if(!sh_check(shield.misc1, shield.misc2, w->id, reflect, w->type&1, true))
6119 return true;
6120
6121 if(reflect && (w->unblockable&WPNUNB_REFL))
6122 reflect = false;
6123 if(!reflect && (w->unblockable&WPNUNB_SHLD))
6124 return true;
6125
6126 int32_t oldid = w->id;
6127 w->onhit(false, reflect ? 2 : 1, dir);
6128
6129 sfx(shield.usesound,pan(x.getInt()));
6130 return true;
6131 }
6132
6133 12942226 int32_t HeroClass::EwpnHit()
6134 {
6135
2/2
✓ Branch 0 taken 12936775 times.
✓ Branch 1 taken 7523644 times.
20460419 for(int32_t i=0; i<Ewpns.Count(); i++)
6136 {
6137
2/2
✓ Branch 0 taken 7512082 times.
✓ Branch 1 taken 11562 times.
7523644 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6138 {
6139 11562 weapon *ew = (weapon*)(Ewpns.spr(i));
6140
6141
3/6
✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11562 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11562 times.
11562 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6142 break;
6143
6144 11562 int32_t stompid = current_item_id(itype_stompboots);
6145
6146
5/10
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11552 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11562 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6147
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 ((z+fakez) > (ew->z+(ew->fakez))) ||
6148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6149 {
6150 itemdata const& stomp = itemsbuf[stompid];
6151 bool reflect = false; //unused, always false
6152 if(!sh_check(stomp.misc2, 0, ew->id, reflect, ew->type&1, true))
6153 {
6154 ew->onhit(false);
6155 sfx(WAV_CHINK,pan(x.getInt()));
6156 continue;
6157 }
6158 }
6159
6160 11562 int32_t defresult = defend(ew);
6161
1/2
✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
11562 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6162
6163
2/2
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 3 times.
11562 if(ew->id==ewWind)
6164 {
6165 3 xofs=1000;
6166 3 action=freeze; FFCore.setHeroAction(freeze);
6167 3 ew->misc=999; // in enemy wind
6168 3 attackclk=0;
6169 3 return -1;
6170 }
6171
6172
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 11468 times.
11559 switch(ew->id)
6173 {
6174 case ewLitBomb:
6175 case ewBomb:
6176 case ewLitSBomb:
6177 case ewSBomb:
6178 91 return i;
6179 }
6180
6181 11468 int32_t itemid = getCurrentShield(false);
6182
4/6
✓ Branch 0 taken 10926 times.
✓ Branch 1 taken 542 times.
✓ Branch 2 taken 10926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10926 times.
11468 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6183 542 return i;
6184 10926 itemdata const& shield = itemsbuf[itemid];
6185 10926 bool allow_inactive = (shield.flags & item_flag9);
6186 10926 auto cmpdir = compareDir(ew->dir);
6187 10926 bool hitshield = compareShield(cmpdir, shield);
6188
6189
12/20
✓ Branch 0 taken 10926 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10926 times.
✓ Branch 4 taken 8816 times.
✓ Branch 5 taken 2110 times.
✓ Branch 6 taken 8816 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8754 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 8754 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8754 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8754 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 8754 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8754 times.
✗ Branch 19 not taken.
10926 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6190 2172 return i;
6191
6192
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1989 times.
8754 if(!hitshield)
6193 1989 return i;
6194
6195 6765 paymagiccost(itemid);
6196
6197 6765 bool reflect = false;
6198
6199
2/2
✓ Branch 0 taken 6111 times.
✓ Branch 1 taken 654 times.
6765 if(!sh_check(shield.misc1, shield.misc2, ew->id, reflect, ew->type&1, true))
6200 654 return i;
6201
6202
3/4
✓ Branch 0 taken 1609 times.
✓ Branch 1 taken 4502 times.
✓ Branch 2 taken 1609 times.
✗ Branch 3 not taken.
6111 if(reflect && (ew->unblockable&WPNUNB_REFL))
6203 reflect = false;
6204
3/4
✓ Branch 0 taken 4502 times.
✓ Branch 1 taken 1609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4502 times.
6111 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6205 return i;
6206
6207 6111 int32_t oldid = ew->id;
6208 6111 ew->onhit(false, reflect ? 2 : 1, dir);
6209
6210 6111 sfx(shield.usesound,pan(x.getInt()));
6211 6111 }
6212 7518193 }
6213
6214 12936775 return -1;
6215 12942226 }
6216
6217 12942236 int32_t HeroClass::LwpnHit() //only here to check magic hits
6218 {
6219
2/2
✓ Branch 0 taken 12771542 times.
✓ Branch 1 taken 4298431 times.
17069973 for(int32_t i=0; i<Lwpns.Count(); i++)
6220
2/2
✓ Branch 0 taken 4127731 times.
✓ Branch 1 taken 170700 times.
4298437 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6221 {
6222 170700 weapon *lw = (weapon*)(Lwpns.spr(i));
6223
6224
2/2
✓ Branch 0 taken 166106 times.
✓ Branch 1 taken 4594 times.
170700 if((lw->ignoreHero)==true)
6225 4594 break;
6226
6227
2/2
✓ Branch 0 taken 166090 times.
✓ Branch 1 taken 16 times.
166106 switch(lw->id)
6228 {
6229 case wRefFireball:
6230 case wRefMagic:
6231 case wRefBeam:
6232 case wRefRock:
6233 case wRefArrow:
6234 case wRefFire:
6235 case wRefFire2:
6236 16 break;
6237 default:
6238 166090 return -1;
6239 }
6240 16 int32_t itemid = getCurrentShield(false);
6241
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
16 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6242 4 return i;
6243 12 itemdata const& shield = itemsbuf[itemid];
6244 12 auto cmpdir = compareDir(lw->dir);
6245 12 bool hitshield = compareShield(cmpdir, shield);
6246 12 bool reflect = false;
6247
6248
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(!hitshield)
6249 6 return i;
6250
6251 6 bool allow_inactive = (shield.flags & item_flag9);
6252
10/20
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
6 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6253 return i;
6254
6255
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!sh_check(shield.misc1, shield.misc2, lw->id, reflect, lw->type&1, true))
6256 return i;
6257
6258 6 paymagiccost(itemid);
6259
6260 6 lw->onhit(false, reflect ? 2 : 1, dir);
6261 6 sfx(shield.usesound,pan(x.getInt()));
6262 6 }
6263
6264 12776136 return -1;
6265 12942236 }
6266
6267 105 bool HeroClass::try_lwpn_hit(weapon* w)
6268 {
6269 105 int32_t itemid = w->parentitem;
6270 105 int indx = Lwpns.find(w);
6271 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6272 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6273
7/12
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 35 times.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
105 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6274 {
6275
2/14
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 35 times.
35 if(w->id==wFire && (superman ? ((diagonalMovement||NO_GRIDLOCK)?w->hit(x+4,y+4-fakez,z,7,7,1):w->hit(x+7,y+7-fakez,z,2,2,1)) : w->hit(this))&&
6276 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6277 {
6278 std::vector<int32_t> &ev = FFCore.eventData;
6279 ev.clear();
6280 ev.push_back(lwpn_dp(indx)*10000);
6281 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6282 ev.push_back(0);
6283 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6284 ev.push_back(48*10000);
6285 ev.push_back(ZSD_LWPN*10000);
6286 ev.push_back(w->getUID());
6287 ev.push_back(ZSD_NONE*10000);
6288 ev.push_back(0);
6289
6290 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6291 int32_t dmg = ev[0]/10000;
6292 bool nullhit = ev[2] != 0;
6293
6294 if(nullhit) {ev.clear(); return true;}
6295
6296 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6297 ev[0] = ringpower(dmg)*10000;
6298
6299 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6300 dmg = ev[0]/10000;
6301 int32_t hdir = ev[1]/10000;
6302 nullhit = ev[2] != 0;
6303 bool divineprot = ev[3] != 0;
6304 int32_t iframes = ev[4] / 10000;
6305 ev.clear();
6306 if(nullhit) return true;
6307 if (Lwpns.spr(indx) != w)
6308 {
6309 auto hit = Lwpns.find(w);
6310 if (hit < 0)
6311 w = nullptr;
6312 else
6313 {
6314 w = (weapon*)Lwpns.spr(hit);
6315 indx = hit;
6316 }
6317 }
6318 if(!divineprot)
6319 {
6320 game->set_life(zc_max(game->get_life()-dmg,0));
6321 if (!get_qr(qr_BROKENHITBY) && w)
6322 {
6323 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6324 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6325 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6326 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6327 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6328 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6329 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6330 }
6331 }
6332
6333 doHit(hdir, iframes);
6334 return true;
6335 }
6336 35 }
6337
6338 // check enemy weapons true, 1, -1
6339 //
6340
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if((itemsbuf[itemid].flags & item_flag6))
6341 {
6342 if(w->id==wBrang || (w->id==wHookshot&&!pull_hero))
6343 {
6344 int32_t itemid = w->parentitem>-1 ? w->parentitem :
6345 directWpn>-1 ? directWpn : current_item_id(w->id==wHookshot ? (w->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6346 itemid = vbound(itemid, 0, MAXITEMS-1);
6347
6348 for(int32_t j=0; j<Ewpns.Count(); j++)
6349 {
6350 sprite *t = Ewpns.spr(j);
6351
6352 if(w->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6353 {
6354 bool reflect = false;
6355 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6356 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6357 {
6358 w->dead=1;
6359 weapon *ew = ((weapon*)t);
6360 int32_t oldid = ew->id;
6361 ew->onhit(true, reflect ? 2 : 1, w->dir);
6362 }
6363
6364 break;
6365 }
6366 }
6367 }
6368 }
6369
6370
2/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6371 {
6372 if(((w->id==wBomb)||(w->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6373 {
6374 bool didhit = w->hit(this);
6375 if(didhit)
6376 {
6377 std::vector<int32_t> &ev = FFCore.eventData;
6378 ev.clear();
6379 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6380 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6381 ev.push_back(0);
6382 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6383 ev.push_back(48*10000);
6384 ev.push_back(ZSD_LWPN*10000);
6385 ev.push_back(w->getUID());
6386 ev.push_back(ZSD_NONE*10000);
6387 ev.push_back(0);
6388
6389 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6390 int32_t dmg = ev[0]/10000;
6391 bool nullhit = ev[2] != 0;
6392
6393 if(nullhit) {ev.clear(); return true;}
6394
6395 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6396 ev[0] = ringpower(dmg)*10000;
6397
6398 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6399 dmg = ev[0]/10000;
6400 int32_t hdir = ev[1]/10000;
6401 nullhit = ev[2] != 0;
6402 bool divineprot = ev[3] != 0;
6403 int32_t iframes = ev[4] / 10000;
6404 ev.clear();
6405 if(nullhit) return true;
6406 if (Lwpns.spr(indx) != w)
6407 {
6408 auto hit = Lwpns.find(w);
6409 if (hit < 0)
6410 w = nullptr;
6411 else
6412 {
6413 w = (weapon*)Lwpns.spr(hit);
6414 indx = hit;
6415 }
6416 }
6417 if(!divineprot)
6418 {
6419 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6420 if (!get_qr(qr_BROKENHITBY) && w)
6421 {
6422 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6423 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6424 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6425 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6426 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6427 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6428 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6429 }
6430 }
6431
6432 doHit(hdir, iframes);
6433 return true;
6434 }
6435 }
6436 }
6437
6438
4/8
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
35 if(hclk==0 && w->id==wWind && w->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6439 {
6440 std::vector<int32_t> &ev = FFCore.eventData;
6441 ev.clear();
6442 ev.push_back(0);
6443 ev.push_back(w->dir*10000);
6444 ev.push_back(0);
6445 ev.push_back(0);
6446 ev.push_back(ZSD_LWPN*10000);
6447 ev.push_back(w->getUID());
6448 ev.push_back(ZSD_NONE*10000);
6449 ev.push_back(0);
6450
6451 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6452 bool nullhit = ev[2] != 0;
6453 if(nullhit) {ev.clear(); return true;}
6454
6455 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6456 int32_t hdir = ev[1]/10000;
6457 nullhit = ev[2] != 0;
6458 ev.clear();
6459 if(nullhit) return true;
6460 if (Lwpns.spr(indx) != w)
6461 {
6462 auto hit = Lwpns.find(w);
6463 if (hit < 0)
6464 w = nullptr;
6465 else
6466 {
6467 w = (weapon*)Lwpns.spr(hit);
6468 indx = hit;
6469 }
6470 }
6471
6472 reset_hookshot();
6473 xofs=1000;
6474 action=inwind; FFCore.setHeroAction(inwind);
6475 dir = hdir;
6476 if(w) w->dir = hdir;
6477 spins = charging = attackclk = 0;
6478
6479 // In case Hero used two whistles in a row, summoning two whirlwinds,
6480 // check which whistle's whirlwind picked him up so the correct
6481 // warp ring will be used
6482 int32_t whistle = w ? w->parentitem : -1;
6483
6484 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6485 whistleitem=whistle;
6486
6487 return true;
6488 }
6489 35 return false;
6490 35 }
6491
6492 bool HeroClass::try_ewpn_hit(weapon* w, bool force)
6493 {
6494 if(!force)
6495 {
6496 if(!check_ewpn_collide(w))
6497 return false;
6498 if(w->ignoreHero || w->fallclk|| w->drownclk)
6499 return false;
6500 }
6501 auto indx = Ewpns.find(w);
6502 std::vector<int32_t> &ev = FFCore.eventData;
6503 ev.clear();
6504 ev.push_back((ewpn_dp(indx)*10000));
6505 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6506 ev.push_back(0);
6507 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6508 ev.push_back(48*10000);
6509 ev.push_back(ZSD_EWPN*10000);
6510 ev.push_back(w->getUID());
6511 ev.push_back(ZSD_NONE*10000);
6512 ev.push_back(0);
6513
6514 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6515 int32_t dmg = ev[0]/10000;
6516 bool nullhit = ev[2] != 0;
6517
6518 if(nullhit) {ev.clear(); return false;}
6519
6520 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6521 ev[0] = ringpower(dmg)*10000;
6522
6523 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6524 dmg = ev[0]/10000;
6525 int32_t hdir = ev[1]/10000;
6526 nullhit = ev[2] != 0;
6527 bool divineprot = ev[3] != 0;
6528 int32_t iframes = ev[4] / 10000;
6529 ev.clear();
6530 if (nullhit) return false;
6531 if (Ewpns.spr(indx) != w)
6532 {
6533 indx = Ewpns.find(w);
6534 if (indx < 0)
6535 w = nullptr;
6536 else w = (weapon*)Ewpns.spr(indx);
6537 }
6538 if (!divineprot)
6539 {
6540 game->set_life(zc_max(game->get_life() - dmg, 0));
6541 if (w)
6542 {
6543 sethitHeroUID(HIT_BY_EWEAPON, (indx + 1));
6544 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getUID());
6545 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, w->getUID());
6546 sethitHeroUID(HIT_BY_EWEAPON_TYPE, w->id);
6547 }
6548 }
6549
6550 if(w)
6551 w->hit_pierce();
6552
6553 doHit(hdir, iframes);
6554 return true;
6555 }
6556
6557 20704092 void HeroClass::checkhit()
6558 {
6559
2/2
✓ Branch 0 taken 6394686 times.
✓ Branch 1 taken 14309406 times.
20704092 if(checkhero==true)
6560 {
6561
2/2
✓ Branch 0 taken 13598262 times.
✓ Branch 1 taken 711144 times.
14309406 if(hclk>0)
6562 {
6563 711144 --hclk;
6564 711144 }
6565
6566
1/2
✓ Branch 0 taken 14309406 times.
✗ Branch 1 not taken.
14309406 if(DivineProtectionShieldClk>0)
6567 {
6568 --DivineProtectionShieldClk;
6569
6570 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6571 {
6572 stop_sfx(itemsbuf[div_prot_item].usesound);
6573 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6574 div_prot_item = -1;
6575 }
6576 else if(get_qr(qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6577 {
6578 stop_sfx(itemsbuf[div_prot_item].usesound);
6579 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6580 }
6581 }
6582 14309406 }
6583
6584
4/4
✓ Branch 0 taken 14173408 times.
✓ Branch 1 taken 6530684 times.
✓ Branch 2 taken 14165589 times.
✓ Branch 3 taken 7819 times.
20704092 if(hclk<39 && action==gothit)
6585 {
6586 7819 action=none; FFCore.setHeroAction(none);
6587 7819 }
6588
6589
5/6
✓ Branch 0 taken 14173408 times.
✓ Branch 1 taken 6530684 times.
✓ Branch 2 taken 14173283 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14173283 times.
20704092 if(hclk<39 && (action==swimhit || action == sideswimhit))
6590 {
6591 125 SetSwim();
6592 125 }
6593
6594
4/4
✓ Branch 0 taken 120977 times.
✓ Branch 1 taken 20583115 times.
✓ Branch 2 taken 34689 times.
✓ Branch 3 taken 86288 times.
20704092 if(hclk>=40 && action==gothit)
6595 {
6596 86288 int val = check_pitslide();
6597
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 85860 times.
✓ Branch 2 taken 86464 times.
✓ Branch 3 taken 86036 times.
86288 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6598 {
6599
2/2
✓ Branch 0 taken 345856 times.
✓ Branch 1 taken 86464 times.
432320 for(int32_t i=0; i<4; i++)
6600 {
6601
5/5
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 73660 times.
✓ Branch 2 taken 83280 times.
✓ Branch 3 taken 90472 times.
✓ Branch 4 taken 94028 times.
345856 switch(hitdir)
6602 {
6603 case up:
6604
6/6
✓ Branch 0 taken 5371 times.
✓ Branch 1 taken 68289 times.
✓ Branch 2 taken 56636 times.
✓ Branch 3 taken 11653 times.
✓ Branch 4 taken 5513 times.
✓ Branch 5 taken 68147 times.
73660 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6605 {
6606 5513 action=none; FFCore.setHeroAction(none);
6607 5513 }
6608
2/2
✓ Branch 0 taken 68123 times.
✓ Branch 1 taken 24 times.
68147 else if (val == -1) --y;
6609
6610 73660 break;
6611
6612 case down:
6613
6/6
✓ Branch 0 taken 6907 times.
✓ Branch 1 taken 76373 times.
✓ Branch 2 taken 13188 times.
✓ Branch 3 taken 63185 times.
✓ Branch 4 taken 7065 times.
✓ Branch 5 taken 76215 times.
83280 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6614 {
6615 7065 action=none; FFCore.setHeroAction(none);
6616 7065 }
6617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76215 times.
76215 else if (val == -1) ++y;
6618
6619 83280 break;
6620
6621 case left:
6622
7/8
✓ Branch 0 taken 87097 times.
✓ Branch 1 taken 3375 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87097 times.
✓ Branch 4 taken 10920 times.
✓ Branch 5 taken 76177 times.
✓ Branch 6 taken 3542 times.
✓ Branch 7 taken 86930 times.
90472 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6623 {
6624 3542 action=none; FFCore.setHeroAction(none);
6625 3542 }
6626
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 86894 times.
86930 else if (val == -1) --x;
6627
6628 90472 break;
6629
6630 case right:
6631
8/8
✓ Branch 0 taken 89968 times.
✓ Branch 1 taken 4060 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 89964 times.
✓ Branch 4 taken 9850 times.
✓ Branch 5 taken 80114 times.
✓ Branch 6 taken 4169 times.
✓ Branch 7 taken 89859 times.
94028 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6632 {
6633 4169 action=none; FFCore.setHeroAction(none);
6634 4169 }
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89859 times.
89859 else if (val == -1) ++x;
6636
6637 94028 break;
6638 }
6639 345856 }
6640 86464 }
6641 86640 }
6642
6643
19/20
✓ Branch 0 taken 13612696 times.
✓ Branch 1 taken 7091748 times.
✓ Branch 2 taken 13611747 times.
✓ Branch 3 taken 949 times.
✓ Branch 4 taken 13593393 times.
✓ Branch 5 taken 18354 times.
✓ Branch 6 taken 13588760 times.
✓ Branch 7 taken 4633 times.
✓ Branch 8 taken 13588561 times.
✓ Branch 9 taken 199 times.
✓ Branch 10 taken 13588561 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13587655 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 13577524 times.
✓ Branch 15 taken 10131 times.
✓ Branch 16 taken 11373 times.
✓ Branch 17 taken 13566151 times.
✓ Branch 18 taken 7799675 times.
✓ Branch 19 taken 7811048 times.
20704444 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6644 {
6645 14926595 return;
6646 }
6647
6648
2/2
✓ Branch 0 taken 12519938 times.
✓ Branch 1 taken 13566113 times.
26086051 for(int32_t i=0; i<Lwpns.Count(); i++)
6649 {
6650 12519938 sprite *s = Lwpns.spr(i);
6651 12519938 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6652 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6653 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6654
12/12
✓ Branch 0 taken 759221 times.
✓ Branch 1 taken 11760717 times.
✓ Branch 2 taken 3949825 times.
✓ Branch 3 taken 7810892 times.
✓ Branch 4 taken 3905017 times.
✓ Branch 5 taken 3905875 times.
✓ Branch 6 taken 3905771 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 91196 times.
✓ Branch 9 taken 3814575 times.
✓ Branch 10 taken 38783 times.
✓ Branch 11 taken 52413 times.
12519938 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6655 {
6656
11/14
✓ Branch 0 taken 3743510 times.
✓ Branch 1 taken 123478 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 123035 times.
✓ Branch 4 taken 443 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 443 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 443 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3711 times.
✓ Branch 11 taken 119324 times.
✓ Branch 12 taken 3866097 times.
✓ Branch 13 taken 33 times.
3870284 if(s->id==wFire && (superman ? ((diagonalMovement||NO_GRIDLOCK)?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296 times.
4154 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6658 {
6659 33 std::vector<int32_t> &ev = FFCore.eventData;
6660 33 ev.clear();
6661 33 ev.push_back(lwpn_dp(i)*10000);
6662 33 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6663 33 ev.push_back(0);
6664 33 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6665 33 ev.push_back(48*10000);
6666 33 ev.push_back(ZSD_LWPN*10000);
6667 33 ev.push_back(s->getUID());
6668 33 ev.push_back(ZSD_NONE*10000);
6669 33 ev.push_back(0);
6670
6671 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6672 33 int32_t dmg = ev[0]/10000;
6673 33 bool nullhit = ev[2] != 0;
6674
6675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) {ev.clear(); return;}
6676
6677 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6678 33 ev[0] = ringpower(dmg)*10000;
6679
6680 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6681 33 dmg = ev[0]/10000;
6682 33 int32_t hdir = ev[1]/10000;
6683 33 nullhit = ev[2] != 0;
6684 33 bool divineprot = ev[3] != 0;
6685 33 int32_t iframes = ev[4] / 10000;
6686 33 ev.clear();
6687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) return;
6688
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (Lwpns.spr(i) != s)
6689 {
6690 auto hit = Lwpns.find(s);
6691 if (hit < 0)
6692 s = nullptr;
6693 else
6694 {
6695 s = Lwpns.spr(hit);
6696 i = hit;
6697 }
6698 }
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!divineprot)
6700 {
6701
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 game->set_life(zc_max(game->get_life()-dmg,0));
6702 33 weapon* w = (weapon*)s;
6703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if (!get_qr(qr_BROKENHITBY) && w)
6704 {
6705 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6706 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6707 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6708 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6709 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6710 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6711 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6712 }
6713 33 }
6714
6715 33 doHit(hdir, iframes);
6716 33 return;
6717 }
6718 3866097 }
6719
6720 // check enemy weapons true, 1, -1
6721 //
6722
2/2
✓ Branch 0 taken 494073 times.
✓ Branch 1 taken 4214940 times.
4709013 if((itemsbuf[itemid].flags & item_flag6))
6723 {
6724
6/6
✓ Branch 0 taken 380644 times.
✓ Branch 1 taken 113429 times.
✓ Branch 2 taken 34343 times.
✓ Branch 3 taken 346301 times.
✓ Branch 4 taken 7231 times.
✓ Branch 5 taken 27112 times.
494073 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6725 {
6726
1/2
✓ Branch 0 taken 140541 times.
✗ Branch 1 not taken.
140541 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6727 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6728 140541 itemid = vbound(itemid, 0, MAXITEMS-1);
6729
6730
2/2
✓ Branch 0 taken 140053 times.
✓ Branch 1 taken 66159 times.
206212 for(int32_t j=0; j<Ewpns.Count(); j++)
6731 {
6732 66159 sprite *t = Ewpns.spr(j);
6733
6734
2/2
✓ Branch 0 taken 65671 times.
✓ Branch 1 taken 488 times.
66159 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6735 {
6736 488 bool reflect = false;
6737 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6738
6739
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 119 times.
488 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->type&1, false))
6740 {
6741 119 ((weapon*)s)->dead=1;
6742 119 weapon *ew = ((weapon*)t);
6743 119 int32_t oldid = ew->id;
6744 119 ew->onhit(true, reflect ? 2 : 1, s->dir);
6745 119 }
6746 488 break;
6747 }
6748 65671 }
6749 140541 }
6750 494073 }
6751
6752
6/6
✓ Branch 0 taken 3064340 times.
✓ Branch 1 taken 1644673 times.
✓ Branch 2 taken 759221 times.
✓ Branch 3 taken 2305119 times.
✓ Branch 4 taken 106519 times.
✓ Branch 5 taken 652702 times.
4709013 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6753 {
6754
7/8
✓ Branch 0 taken 1705751 times.
✓ Branch 1 taken 45441 times.
✓ Branch 2 taken 45989 times.
✓ Branch 3 taken 1705203 times.
✓ Branch 4 taken 45989 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 45960 times.
1751192 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6755 {
6756 45960 weapon* w = (weapon*)s;
6757 45960 bool didhit = s->hit(this);
6758
2/2
✓ Branch 0 taken 45925 times.
✓ Branch 1 taken 35 times.
45960 if(didhit)
6759 {
6760 35 std::vector<int32_t> &ev = FFCore.eventData;
6761 35 ev.clear();
6762
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6763 35 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6764 35 ev.push_back(0);
6765 35 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6766 35 ev.push_back(48*10000);
6767 35 ev.push_back(ZSD_LWPN*10000);
6768 35 ev.push_back(w->getUID());
6769 35 ev.push_back(ZSD_NONE*10000);
6770 35 ev.push_back(0);
6771
6772 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6773 35 int32_t dmg = ev[0]/10000;
6774 35 bool nullhit = ev[2] != 0;
6775
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) {ev.clear(); return;}
6777
6778 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6779 35 ev[0] = ringpower(dmg)*10000;
6780
6781 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6782 35 dmg = ev[0]/10000;
6783 35 int32_t hdir = ev[1]/10000;
6784 35 nullhit = ev[2] != 0;
6785 35 bool divineprot = ev[3] != 0;
6786 35 int32_t iframes = ev[4] / 10000;
6787 35 ev.clear();
6788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) return;
6789
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (Lwpns.spr(i) != w)
6790 {
6791 auto hit = Lwpns.find(w);
6792 if (hit < 0)
6793 s = nullptr;
6794 else
6795 {
6796 s = Lwpns.spr(hit);
6797 i = hit;
6798 }
6799 w = (weapon*)s;
6800 }
6801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!divineprot)
6802 {
6803
5/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
35 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6804
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
35 if (!get_qr(qr_BROKENHITBY) && w)
6805 {
6806 1 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6807 1 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6808 1 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6809 1 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6811 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6812 1 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].family);
6813 1 }
6814 35 }
6815
6816 35 doHit(hdir, iframes);
6817 35 return;
6818 }
6819 45925 }
6820 1751157 }
6821
6822
7/8
✓ Branch 0 taken 4708978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10046 times.
✓ Branch 3 taken 4698932 times.
✓ Branch 4 taken 9920 times.
✓ Branch 5 taken 126 times.
✓ Branch 6 taken 4708852 times.
✓ Branch 7 taken 126 times.
4708978 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6823 {
6824 126 std::vector<int32_t> &ev = FFCore.eventData;
6825 126 ev.clear();
6826 126 ev.push_back(0);
6827 126 ev.push_back(s->dir*10000);
6828 126 ev.push_back(0);
6829 126 ev.push_back(0);
6830 126 ev.push_back(ZSD_LWPN*10000);
6831 126 ev.push_back(s->getUID());
6832 126 ev.push_back(ZSD_NONE*10000);
6833 126 ev.push_back(0);
6834
6835 126 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6836 126 bool nullhit = ev[2] != 0;
6837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(nullhit) {ev.clear(); return;}
6838
6839 126 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6840 126 int32_t hdir = ev[1]/10000;
6841 126 nullhit = ev[2] != 0;
6842 126 ev.clear();
6843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(nullhit) return;
6844
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (Lwpns.spr(i) != s)
6845 {
6846 auto hit = Lwpns.find(s);
6847 if (hit < 0)
6848 s = nullptr;
6849 else
6850 {
6851 s = Lwpns.spr(hit);
6852 i = hit;
6853 }
6854 }
6855
6856 126 reset_hookshot();
6857 126 xofs=1000;
6858 126 action=inwind; FFCore.setHeroAction(inwind);
6859 126 dir = hdir;
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(s) s->dir = hdir;
6861 126 spins = charging = attackclk = 0;
6862
6863 // In case Hero used two whistles in a row, summoning two whirlwinds,
6864 // check which whistle's whirlwind picked him up so the correct
6865 // warp ring will be used
6866
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 int32_t whistle=s ? ((weapon*)s)->parentitem : -1;
6867
6868
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6869 126 whistleitem=whistle;
6870
6871 126 return;
6872 }
6873 4708852 }
6874
6875
6/8
✓ Branch 0 taken 13453251 times.
✓ Branch 1 taken 112862 times.
✓ Branch 2 taken 13145121 times.
✓ Branch 3 taken 308130 times.
✓ Branch 4 taken 13145121 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13141254 times.
26707367 if(action==rafting || action==freeze || action==sideswimfreeze ||
6876
5/8
✓ Branch 0 taken 13141254 times.
✓ Branch 1 taken 3867 times.
✓ Branch 2 taken 13141254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13141254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13141254 times.
✗ Branch 7 not taken.
13145121 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6877 424859 return;
6878
6879 13141254 int32_t hit2 = -1;
6880 13141254 do
6881 {
6882
4/6
✓ Branch 0 taken 8850935 times.
✓ Branch 1 taken 4306830 times.
✓ Branch 2 taken 8850935 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8850935 times.
13157765 hit2 = (diagonalMovement||NO_GRIDLOCK) ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6883 8850935 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6884
6885
2/2
✓ Branch 0 taken 13126786 times.
✓ Branch 1 taken 30979 times.
13157765 if(hit2!=-1)
6886 {
6887
2/2
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 14468 times.
30979 if (hithero(hit2) == 0) return;
6888 16511 }
6889
2/2
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13126786 times.
13143297 } while (hit2 != -1);
6890
6/6
✓ Branch 0 taken 12955572 times.
✓ Branch 1 taken 171214 times.
✓ Branch 2 taken 12945229 times.
✓ Branch 3 taken 10343 times.
✓ Branch 4 taken 2993 times.
✓ Branch 5 taken 12942236 times.
13126786 if (superman || !scriptcoldet || fallclk) return;
6891 12942236 hit2 = LwpnHit();
6892
6893
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12942226 times.
12942236 if(hit2!=-1)
6894 {
6895 10 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6896 10 std::vector<int32_t> &ev = FFCore.eventData;
6897 10 ev.clear();
6898 10 ev.push_back((lwpn_dp(hit2)*10000));
6899 10 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6900 10 ev.push_back(0);
6901 10 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6902 10 ev.push_back(48*10000);
6903 10 ev.push_back(ZSD_LWPN*10000);
6904 10 ev.push_back(lwpnspr->getUID());
6905 10 ev.push_back(ZSD_NONE*10000);
6906 10 ev.push_back(0);
6907
6908 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6909 10 int32_t dmg = ev[0]/10000;
6910 10 bool nullhit = ev[2] != 0;
6911
6912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) {ev.clear(); return;}
6913
6914 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6915 10 ev[0] = ringpower(dmg)*10000;
6916
6917 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6918 10 dmg = ev[0]/10000;
6919 10 int32_t hdir = ev[1]/10000;
6920 10 nullhit = ev[2] != 0;
6921 10 bool divineprot = ev[3] != 0;
6922 10 int32_t iframes = ev[4] / 10000;
6923 10 ev.clear();
6924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) return;
6925
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (Lwpns.spr(hit2) != lwpnspr)
6926 {
6927 hit2 = Lwpns.find(lwpnspr);
6928 if (hit2 < 0)
6929 lwpnspr = nullptr;
6930 else lwpnspr = (weapon*)Lwpns.spr(hit2);
6931 }
6932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!divineprot)
6933 {
6934
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 game->set_life(zc_max(game->get_life() - dmg, 0));
6935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (lwpnspr)
6936 {
6937 10 sethitHeroUID(HIT_BY_LWEAPON, (hit2 + 1));
6938 10 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getUID());
6939 10 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID, lwpnspr->getUID());
6940 10 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
6941
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
6942 8 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6943 10 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
6944 10 }
6945 10 }
6946
6947
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lwpnspr)
6948 10 lwpnspr->hit_pierce();
6949
6950 10 doHit(hdir, iframes);
6951 10 return;
6952 }
6953
6954 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6955
6956 12942226 hit2 = EwpnHit();
6957
6958
2/2
✓ Branch 0 taken 5448 times.
✓ Branch 1 taken 12936778 times.
12942226 if(hit2!=-1)
6959 {
6960 5448 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6961 5448 std::vector<int32_t> &ev = FFCore.eventData;
6962 5448 ev.clear();
6963 5448 ev.push_back((ewpn_dp(hit2)*10000));
6964 5448 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6965 5448 ev.push_back(0);
6966 5448 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6967 5448 ev.push_back(48*10000);
6968 5448 ev.push_back(ZSD_EWPN*10000);
6969 5448 ev.push_back(ewpnspr->getUID());
6970 5448 ev.push_back(ZSD_NONE*10000);
6971 5448 ev.push_back(0);
6972
6973 5448 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6974 5448 int32_t dmg = ev[0]/10000;
6975 5448 bool nullhit = ev[2] != 0;
6976
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if(nullhit) {ev.clear(); return;}
6978
6979 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6980 5448 ev[0] = ringpower(dmg)*10000;
6981
6982 5448 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6983 5448 dmg = ev[0]/10000;
6984 5448 int32_t hdir = ev[1]/10000;
6985 5448 nullhit = ev[2] != 0;
6986 5448 bool divineprot = ev[3] != 0;
6987 5448 int32_t iframes = ev[4] / 10000;
6988 5448 ev.clear();
6989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (nullhit) return;
6990
1/2
✓ Branch 0 taken 5448 times.
✗ Branch 1 not taken.
5448 if (Ewpns.spr(hit2) != ewpnspr)
6991 {
6992 hit2 = Ewpns.find(ewpnspr);
6993 if (hit2 < 0)
6994 ewpnspr = nullptr;
6995 else ewpnspr = (weapon*)Ewpns.spr(hit2);
6996 }
6997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (!divineprot)
6998 {
6999
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5402 times.
5448 game->set_life(zc_max(game->get_life() - dmg, 0));
7000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (ewpnspr)
7001 {
7002 5448 sethitHeroUID(HIT_BY_EWEAPON, (hit2 + 1));
7003 5448 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getUID());
7004 5448 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, ewpnspr->getUID());
7005 5448 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
7006 5448 }
7007 5448 }
7008
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if(ewpnspr)
7010 5448 ewpnspr->hit_pierce();
7011
7012 5448 doHit(hdir, iframes);
7013 5448 return;
7014 }
7015
7016 // The rest of this method deals with damage combos, which can be jumped over.
7017
4/4
✓ Branch 0 taken 12918400 times.
✓ Branch 1 taken 18378 times.
✓ Branch 2 taken 12918653 times.
✓ Branch 3 taken 18125 times.
12936778 if((z>0 || fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) return;
7018
7019 12918653 int32_t dx1 = (int32_t)x+8-(hero_scr->csensitive);
7020 12918653 int32_t dx2 = (int32_t)x+8+(hero_scr->csensitive-1);
7021
2/2
✓ Branch 0 taken 284213 times.
✓ Branch 1 taken 12634440 times.
12918653 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?hero_scr->csensitive:(hero_scr->csensitive+1)/2);
7022
2/2
✓ Branch 0 taken 284213 times.
✓ Branch 1 taken 12634440 times.
12918653 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?hero_scr->csensitive-1:((hero_scr->csensitive+1)/2)-1);
7023
7024
2/2
✓ Branch 0 taken 24015069 times.
✓ Branch 1 taken 12918653 times.
36933722 for(int32_t i=get_qr(qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
7025 24015069 checkdamagecombos(dx1,dx2,dy1,dy2,i);
7026 14309406 }
7027
7028 17639 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
7029 {
7030 17639 return checkdamagecombos(dx,dx,dy,dy);
7031 }
7032
7033 6055 void HeroClass::doHit(int32_t hdir, int iframes)
7034 {
7035 6055 hitdir = hdir;
7036
7037
3/6
✓ Branch 0 taken 6055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6055 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6055 times.
6055 if (action != rafting && action != freeze && action != sideswimfreeze)
7038 {
7039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6055 times.
6055 if (IsSideSwim())
7040 {
7041 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7042 }
7043
3/4
✓ Branch 0 taken 5987 times.
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5987 times.
6055 else if (action == swimming || hopclk == 0xFF)
7044 {
7045 68 action=swimhit; FFCore.setHeroAction(swimhit);
7046 68 }
7047 else
7048 {
7049 5987 action=gothit; FFCore.setHeroAction(gothit);
7050 }
7051 6055 }
7052
7053 6055 hclk = iframes;
7054 6055 check_on_hit();
7055
7056
8/8
✓ Branch 0 taken 6022 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 6021 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2365 times.
✓ Branch 5 taken 3656 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2209 times.
6055 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7057 {
7058 3846 spins = charging = attackclk = 0;
7059 3846 attack=none;
7060 3846 tapping = false;
7061 3846 }
7062
7063 6055 sfx(getHurtSFX(),pan(x.getInt()));
7064 6055 }
7065
7066 24515272 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
7067 {
7068
5/6
✓ Branch 0 taken 24515012 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 24512821 times.
✓ Branch 3 taken 2191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24512821 times.
24515272 if(hclk || superman || fallclk)
7069 2451 return false;
7070
7071 24512821 int32_t hp_mod[4] = {0};
7072 int32_t cid[8];
7073 24512821 byte hasKB = 0;
7074
7075 {
7076
2/2
✓ Branch 0 taken 11416496 times.
✓ Branch 1 taken 13096325 times.
24512821 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
7077 24512821 newcombo& cmb = combobuf[cid[0]];
7078
4/4
✓ Branch 0 taken 24512818 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510999 times.
✓ Branch 3 taken 1819 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7079 {
7080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(cmb.usrflags&cflag1)
7081 hp_mod[0] = cmb.attributes[0] / -10000L;
7082 else
7083 1819 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(!(cmb.usrflags&cflag2))
7085 1819 hasKB |= 1<<0;
7086 1819 }
7087 }
7088 {
7089
2/2
✓ Branch 0 taken 11416496 times.
✓ Branch 1 taken 13096325 times.
24512821 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
7090 24512821 newcombo& cmb = combobuf[cid[1]];
7091
4/4
✓ Branch 0 taken 24512818 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510953 times.
✓ Branch 3 taken 1865 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7092 {
7093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(cmb.usrflags&cflag1)
7094 hp_mod[1] = cmb.attributes[0] / -10000L;
7095 else
7096 1865 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(!(cmb.usrflags&cflag2))
7098 1865 hasKB |= 1<<1;
7099 1865 }
7100 }
7101 {
7102
2/2
✓ Branch 0 taken 11416496 times.
✓ Branch 1 taken 13096325 times.
24512821 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
7103 24512821 newcombo& cmb = combobuf[cid[2]];
7104
4/4
✓ Branch 0 taken 24512818 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510992 times.
✓ Branch 3 taken 1826 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7105 {
7106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(cmb.usrflags&cflag1)
7107 hp_mod[2] = cmb.attributes[0] / -10000L;
7108 else
7109 1826 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(!(cmb.usrflags&cflag2))
7111 1826 hasKB |= 1<<2;
7112 1826 }
7113 }
7114 {
7115
2/2
✓ Branch 0 taken 11416496 times.
✓ Branch 1 taken 13096325 times.
24512821 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
7116 24512821 newcombo& cmb = combobuf[cid[3]];
7117
4/4
✓ Branch 0 taken 24512818 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510935 times.
✓ Branch 3 taken 1883 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7118 {
7119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(cmb.usrflags&cflag1)
7120 hp_mod[3] = cmb.attributes[0] / -10000L;
7121 else
7122 1883 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(!(cmb.usrflags&cflag2))
7124 1883 hasKB |= 1<<3;
7125 1883 }
7126 }
7127
7128 24512821 int32_t bestcid=0;
7129 24512821 rpos_t best_rpos = rpos_t::None;
7130 24512821 int32_t hp_modtotal=0;
7131 24512821 rpos_t rposes[] = {COMBOPOS_REGION_B(dx1,dy1),COMBOPOS_REGION_B(dx1,dy2),COMBOPOS_REGION_B(dx2,dy1),COMBOPOS_REGION_B(dx2,dy2)};
7132
2/2
✓ Branch 0 taken 24384461 times.
✓ Branch 1 taken 128360 times.
24512821 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7133
2/2
✓ Branch 0 taken 24374501 times.
✓ Branch 1 taken 138320 times.
24512821 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7134
2/2
✓ Branch 0 taken 24384497 times.
✓ Branch 1 taken 128324 times.
24512821 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7135
2/2
✓ Branch 0 taken 24374535 times.
✓ Branch 1 taken 138286 times.
24512821 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7136
7137
2/2
✓ Branch 0 taken 49025642 times.
✓ Branch 1 taken 24512821 times.
73538463 for (int32_t i = 0; i <= 1; ++i)
7138 {
7139
2/2
✓ Branch 0 taken 44132314 times.
✓ Branch 1 taken 4893328 times.
49025642 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7140 {
7141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7145 44132314 }
7146 else
7147 {
7148
4/4
✓ Branch 0 taken 12191 times.
✓ Branch 1 taken 4881137 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 9653 times.
4893328 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7149
4/4
✓ Branch 0 taken 12221 times.
✓ Branch 1 taken 4881107 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 9623 times.
4893328 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7150
4/4
✓ Branch 0 taken 12212 times.
✓ Branch 1 taken 4881116 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 9590 times.
4893328 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7151
4/4
✓ Branch 0 taken 12245 times.
✓ Branch 1 taken 4881083 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 9560 times.
4893328 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7152 }
7153 49025642 }
7154
7155
2/2
✓ Branch 0 taken 98051284 times.
✓ Branch 1 taken 24512821 times.
122564105 for(int32_t i=0; i<4; i++)
7156 {
7157
2/2
✓ Branch 0 taken 98048484 times.
✓ Branch 1 taken 2800 times.
98051284 if (rposes[i] == rpos_t::None)
7158 2800 continue;
7159
7160
2/2
✓ Branch 0 taken 37155700 times.
✓ Branch 1 taken 60892784 times.
98048484 if(get_qr(qr_DMGCOMBOPRI))
7161 {
7162
2/2
✓ Branch 0 taken 37155314 times.
✓ Branch 1 taken 386 times.
37155700 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7163 {
7164
2/2
✓ Branch 0 taken 37155156 times.
✓ Branch 1 taken 158 times.
37155314 if(hp_mod[i] < hp_modtotal)
7165 {
7166 158 hp_modtotal = hp_mod[i];
7167 158 bestcid = cid[i];
7168 158 best_rpos = rposes[i];
7169 158 }
7170 37155314 }
7171
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 298 times.
386 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7172 {
7173
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 if(hp_mod[i] > hp_modtotal)
7174 {
7175 hp_modtotal = hp_mod[i];
7176 bestcid = cid[i];
7177 best_rpos = rposes[i];
7178 }
7179 298 }
7180 37155700 }
7181
2/2
✓ Branch 0 taken 60890860 times.
✓ Branch 1 taken 1924 times.
60892784 else if(hp_mod[i] < hp_modtotal)
7182 {
7183 1924 hp_modtotal = hp_mod[i];
7184 1924 bestcid = cid[i];
7185 1924 best_rpos = rposes[i];
7186 1924 }
7187 98048484 }
7188
7189 24512821 int ffc_ids[] = {-1, -1, -1, -1};
7190 {
7191 24512821 auto ffc_handle = getFFCAt(dx1,dy1);
7192
2/2
✓ Branch 0 taken 391979 times.
✓ Branch 1 taken 24120842 times.
24512821 ffc_ids[0] = ffc_handle ? ffc_handle->id : -1;
7193
2/2
✓ Branch 0 taken 391979 times.
✓ Branch 1 taken 24120842 times.
24512821 cid[4] = ffc_handle ? ffc_handle->data() : 0;
7194 24512821 newcombo& cmb = combobuf[cid[4]];
7195
4/4
✓ Branch 0 taken 24512626 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 24512578 times.
✓ Branch 3 taken 48 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7196 {
7197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(cmb.usrflags&cflag1 )
7198 hp_mod[0] = cmb.attributes[0]/-10000L;
7199 else
7200 48 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(cmb.usrflags&cflag2))
7202 48 hasKB |= 1<<4;
7203 48 }
7204 }
7205 {
7206 24512821 auto ffc_handle = getFFCAt(dx1,dy2);
7207
2/2
✓ Branch 0 taken 389118 times.
✓ Branch 1 taken 24123703 times.
24512821 ffc_ids[1] = ffc_handle ? ffc_handle->id : -1;
7208
2/2
✓ Branch 0 taken 389118 times.
✓ Branch 1 taken 24123703 times.
24512821 cid[5] = ffc_handle ? ffc_handle->data() : 0;
7209 24512821 newcombo& cmb = combobuf[cid[5]];
7210
4/4
✓ Branch 0 taken 24512617 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 24512573 times.
✓ Branch 3 taken 44 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7211 {
7212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(cmb.usrflags&cflag1 )
7213 hp_mod[1] = cmb.attributes[0]/-10000L;
7214 else
7215 44 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(!(cmb.usrflags&cflag2))
7217 44 hasKB |= 1<<5;
7218 44 }
7219 }
7220 {
7221 24512821 auto ffc_handle = getFFCAt(dx2,dy1);
7222
2/2
✓ Branch 0 taken 396048 times.
✓ Branch 1 taken 24116773 times.
24512821 ffc_ids[2] = ffc_handle ? ffc_handle->id : -1;
7223
2/2
✓ Branch 0 taken 396048 times.
✓ Branch 1 taken 24116773 times.
24512821 cid[6] = ffc_handle ? ffc_handle->data() : 0;
7224 24512821 newcombo& cmb = combobuf[cid[6]];
7225
4/4
✓ Branch 0 taken 24512629 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24512582 times.
✓ Branch 3 taken 47 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7226 {
7227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7228 hp_mod[2] = cmb.attributes[0]/-10000L;
7229 else
7230 47 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7232 47 hasKB |= 1<<6;
7233 47 }
7234 }
7235 {
7236 24512821 auto ffc_handle = getFFCAt(dx2,dy2);
7237
2/2
✓ Branch 0 taken 393151 times.
✓ Branch 1 taken 24119670 times.
24512821 ffc_ids[3] = ffc_handle ? ffc_handle->id : -1;
7238
2/2
✓ Branch 0 taken 393151 times.
✓ Branch 1 taken 24119670 times.
24512821 cid[7] = ffc_handle ? ffc_handle->data() : 0;
7239 24512821 newcombo& cmb = combobuf[cid[7]];
7240
4/4
✓ Branch 0 taken 24512620 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 24512575 times.
✓ Branch 3 taken 45 times.
24512821 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7241 {
7242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(cmb.usrflags&cflag1 )
7243 hp_mod[3] = cmb.attributes[0]/-10000L;
7244 else
7245 45 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!(cmb.usrflags&cflag2))
7247 45 hasKB |= 1<<7;
7248 45 }
7249 }
7250
7251 24512821 int32_t bestffccid = 0;
7252 24512821 int best_ffcid = -1;
7253 24512821 int32_t hp_modtotalffc = 0;
7254
7255
2/2
✓ Branch 0 taken 49025642 times.
✓ Branch 1 taken 24512821 times.
73538463 for (int32_t i = 0; i <= 1; ++i)
7256 {
7257
2/2
✓ Branch 0 taken 44132314 times.
✓ Branch 1 taken 4893328 times.
49025642 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7258 {
7259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7263 44132314 }
7264 else
7265 {
7266
4/4
✓ Branch 0 taken 12191 times.
✓ Branch 1 taken 4881137 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 9653 times.
4893328 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7267
4/4
✓ Branch 0 taken 12221 times.
✓ Branch 1 taken 4881107 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 9623 times.
4893328 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7268
4/4
✓ Branch 0 taken 12212 times.
✓ Branch 1 taken 4881116 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 9590 times.
4893328 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7269
4/4
✓ Branch 0 taken 12245 times.
✓ Branch 1 taken 4881083 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 9560 times.
4893328 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7270 }
7271 49025642 }
7272
7273
2/2
✓ Branch 0 taken 98051284 times.
✓ Branch 1 taken 24512821 times.
122564105 for(int32_t i=0; i<4; i++)
7274 {
7275
2/2
✓ Branch 0 taken 1570296 times.
✓ Branch 1 taken 96480988 times.
98051284 if (ffc_ids[i] == -1) continue;
7276
7277
2/2
✓ Branch 0 taken 224165 times.
✓ Branch 1 taken 1346131 times.
1570296 if(get_qr(qr_DMGCOMBOPRI))
7278 {
7279
2/2
✓ Branch 0 taken 224049 times.
✓ Branch 1 taken 116 times.
224165 if(hp_modtotalffc >= 0)
7280 {
7281
2/2
✓ Branch 0 taken 223984 times.
✓ Branch 1 taken 65 times.
224049 if(hp_mod[i] < hp_modtotalffc)
7282 {
7283 65 hp_modtotalffc = hp_mod[i];
7284 65 bestffccid = cid[4+i];
7285 65 best_ffcid = ffc_ids[i];
7286 65 }
7287 224049 }
7288
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 else if(hp_mod[i] < 0)
7289 {
7290
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(hp_mod[i] > hp_modtotalffc)
7291 {
7292 hp_modtotalffc = hp_mod[i];
7293 bestffccid = cid[4+i];
7294 best_ffcid = ffc_ids[i];
7295 }
7296 112 }
7297 224165 }
7298
2/2
✓ Branch 0 taken 1346105 times.
✓ Branch 1 taken 26 times.
1346131 else if(hp_mod[i] < hp_modtotalffc)
7299 {
7300 26 hp_modtotalffc = hp_mod[i];
7301 26 bestffccid = cid[4+i];
7302 26 best_ffcid = ffc_ids[i];
7303 26 }
7304 1570296 }
7305
7306 mapscr* damage_scr;
7307
2/2
✓ Branch 0 taken 2058 times.
✓ Branch 1 taken 24510763 times.
24512821 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7308 24512821 int best_type = 0;
7309
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 24512754 times.
24512821 if(hp_modtotalffc < hp_modtotal)
7310 {
7311 67 damage_scr = get_ffc_handle(best_ffcid).scr;
7312 67 bestcid = bestffccid;
7313 67 best_type = 1;
7314 67 }
7315 else
7316 {
7317 24512754 damage_scr = get_scr_for_rpos(best_rpos);
7318 }
7319
7320 24512821 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & item_flag1));
7321 24512821 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & item_flag1));
7322
7323 24512821 bool current_ring = ((hero_scr->flags6&fTOGGLERINGDAMAGE) != 0);
7324
1/2
✓ Branch 0 taken 24512821 times.
✗ Branch 1 not taken.
24512821 if(current_ring)
7325 {
7326 global_defring = !global_defring;
7327 global_perilring = !global_perilring;
7328 }
7329 24512821 int32_t itemid = current_item_id(itype_boots);
7330
7331
2/2
✓ Branch 0 taken 23530005 times.
✓ Branch 1 taken 982816 times.
24512821 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & item_flag1);
7332
2/2
✓ Branch 0 taken 23530005 times.
✓ Branch 1 taken 982816 times.
24512821 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & item_flag3);
7333
7334
2/2
✓ Branch 0 taken 24510682 times.
✓ Branch 1 taken 2139 times.
24512821 if(hp_modmin<0)
7335 {
7336
10/14
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 1614 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1614 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1614 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 1609 times.
✓ Branch 10 taken 1614 times.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1614 times.
2139 if((itemid<0) || ignoreBoots || (damage_scr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7337 {
7338
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 6 times.
535 if (!do_health_check) return true;
7339 529 std::vector<int32_t> &ev = FFCore.eventData;
7340 529 ev.clear();
7341 529 ev.push_back(-hp_modmin*10000);
7342
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 ev.push_back((hasKB ? dir^1 : -1)*10000);
7343 529 ev.push_back(0);
7344 529 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7345 529 ev.push_back(48*10000);
7346 529 ev.push_back(ZSD_COMBODATA*10000);
7347 529 ev.push_back(bestcid);
7348 529 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7349
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 462 times.
529 ev.push_back((best_type ? best_ffcid : (int)best_rpos)*10000);
7350
7351 529 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7352 529 int32_t dmg = ev[0]/10000;
7353 529 bool nullhit = ev[2] != 0;
7354
7355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(nullhit) {ev.clear(); return false;}
7356
7357 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7358 529 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7359
7360 529 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7361 529 dmg = ev[0]/10000;
7362 529 int32_t hdir = ev[1]/10000;
7363 529 nullhit = ev[2] != 0;
7364 529 bool divineprot = ev[3] != 0;
7365 529 int32_t iframes = ev[4] / 10000;
7366 529 ev.clear();
7367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(nullhit) return false;
7368
7369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(!divineprot)
7370 {
7371
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 19 times.
529 game->set_life(zc_max(game->get_life()-dmg,0));
7372 529 }
7373
7374 529 hitdir = hdir;
7375 529 doHit(hitdir, iframes);
7376 529 return true;
7377 }
7378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1614 times.
1614 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7379 1614 }
7380
7381 24512296 return false;
7382 24515282 }
7383
7384 31136 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7385 {
7386
1/2
✓ Branch 0 taken 31136 times.
✗ Branch 1 not taken.
31136 if(force_hdir > 3) force_hdir = -1;
7387 31136 enemy* enemyptr = (enemy*)guys.spr(hit2);
7388
1/2
✓ Branch 0 taken 31136 times.
✗ Branch 1 not taken.
31136 if(!enemyptr) return 0;
7389 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7390 31136 int32_t stompid = current_item_id(itype_stompboots);
7391
5/10
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 31119 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
31136 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7392
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7393
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7394 {
7395 paymagiccost(stompid);
7396 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7397
7398 if(itemsbuf[stompid].flags & item_flag1)
7399 {
7400 fall = -(itemsbuf[stompid].misc1);
7401 }
7402
7403 if(itemsbuf[stompid].flags & item_downgrade)
7404 game->set_item(stompid,false);
7405
7406 // Stomp Boots script
7407 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
7408 {
7409 int i = stompid;
7410 FFCore.reset_script_engine_data(ScriptType::Item, i);
7411 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7412 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
7413 }
7414
7415 return -1;
7416 }
7417
6/6
✓ Branch 0 taken 26658 times.
✓ Branch 1 taken 4478 times.
✓ Branch 2 taken 25870 times.
✓ Branch 3 taken 788 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 25823 times.
31136 else if(superman || !scriptcoldet || fallclk)
7418 5313 return 0;
7419 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7420 //!Add a flag check to this if:
7421
5/6
✓ Branch 0 taken 9469 times.
✓ Branch 1 taken 16354 times.
✓ Branch 2 taken 9469 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2703 times.
✓ Branch 5 taken 6766 times.
25825 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7422
4/4
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9213 times.
9469 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7423 {
7424 16608 return -1;
7425 }
7426
7427 9215 std::vector<int32_t> &ev = FFCore.eventData;
7428 9215 ev.clear();
7429 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7430 9215 ev.push_back((enemy_dp(hit2) *10000));
7431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9215 times.
9215 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7432 9215 ev.push_back(0);
7433 9215 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7434 9215 ev.push_back(48*10000);
7435 9215 ev.push_back(ZSD_NPC*10000);
7436 9215 ev.push_back(enemyptr->getUID());
7437 9215 ev.push_back(ZSD_NONE*10000);
7438 9215 ev.push_back(0);
7439
7440 9215 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7441 9215 int32_t dmg = ev[0] / 10000;
7442 9215 bool nullhit = ev[2] != 0;
7443
7444
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9214 times.
9215 if(nullhit) {ev.clear(); return -1;}
7445
7446 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7447 9214 ev[0] = ((ringpower(dmg)*10000));
7448
7449 9214 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7450 9214 dmg = ev[0] / 10000;
7451 9214 int32_t hdir = ev[1] / 10000;
7452 9214 nullhit = ev[2] != 0;
7453 9214 bool divineprot = ev[3] != 0;
7454 9214 int32_t iframes = ev[4] / 10000;
7455 9214 ev.clear();
7456
7457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if(nullhit) return -1;
7458
7459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if(!divineprot)
7460 {
7461
2/2
✓ Branch 0 taken 9158 times.
✓ Branch 1 taken 56 times.
9214 game->set_life(zc_max(game->get_life()-dmg,0));
7462 9214 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7463 9214 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7464 9214 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7465 9214 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7466 9214 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7467 9214 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7468 9214 }
7469
7470 9214 hitdir = hdir;
7471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if (IsSideSwim())
7472 {
7473 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7474 }
7475
3/4
✓ Branch 0 taken 9144 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9144 times.
9214 else if(action==swimming || hopclk==0xFF)
7476 {
7477 70 action=swimhit; FFCore.setHeroAction(swimhit);
7478 70 }
7479 else
7480 {
7481 9144 action=gothit; FFCore.setHeroAction(gothit);
7482 }
7483
7484 9214 hclk=iframes;
7485 9214 check_on_hit();
7486 9214 sfx(getHurtSFX(),pan(x.getInt()));
7487
7488
8/8
✓ Branch 0 taken 9190 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 9187 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3775 times.
✓ Branch 5 taken 5412 times.
✓ Branch 6 taken 159 times.
✓ Branch 7 taken 3616 times.
9214 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7489 {
7490 5598 spins = charging = attackclk = 0;
7491 5598 attack=none;
7492 5598 tapping = false;
7493 5598 }
7494
7495 9214 enemy_scored(hit2);
7496 9214 int32_t dm7 = enemyptr->dmisc7;
7497 9214 int32_t dm8 = enemyptr->dmisc8;
7498
7499
3/3
✓ Branch 0 taken 4524 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4681 times.
9214 switch(enemyptr->family)
7500 {
7501 case eeWALLM:
7502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(enemyptr->hp>0)
7503 {
7504 9 GrabHero(hit2);
7505 9 inwallm=true;
7506 9 action=none; FFCore.setHeroAction(none);
7507 9 }
7508 9 break;
7509
7510 //case eBUBBLEST:
7511 //case eeBUBBLE:
7512 case eeWALK:
7513 {
7514 4681 int32_t itemid = current_item_id(itype_whispring);
7515 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7516
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4681 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7517
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4681 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7518
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✓ Branch 2 taken 875 times.
✗ Branch 3 not taken.
4681 int32_t shielddivisor = ((itemid > -1 && itemsbuf[itemid].misc1 & 4) ? itemsbuf[itemid].power : 1);
7519
7/7
✓ Branch 0 taken 3800 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 6 times.
4681 switch(dm7)
7520 {
7521 case e7tTEMPJINX:
7522
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 400 times.
448 if(dm8&e8tSWORD)
7523
4/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 386 times.
786 if(swordclk>=0 && !(sworddivisor==0))
7524 386 swordclk=int32_t(150/sworddivisor);
7525
7526
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 50 times.
448 if(dm8&e8tITEM)
7527
3/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 49 times.
99 if(itemclk>=0 && !(itemdivisor==0))
7528 49 itemclk=int32_t(150/itemdivisor);
7529
7530
1/2
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
448 if(dm8&e8tSHIELD)
7531 if (shieldjinxclk >= 0 && !(shielddivisor==0))
7532 shieldjinxclk=int32_t(150/shielddivisor);
7533
7534 448 break;
7535
7536 case e7tPERMJINX:
7537
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 99 times.
145 if (dm8&e8tSWORD)
7538
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
99 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/sworddivisor) : -1;
7539
7540
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 46 times.
145 if (dm8&e8tITEM)
7541
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
46 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/itemdivisor) : -1;
7542
7543
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if (dm8&e8tSHIELD)
7544 if(shielddivisor) shieldjinxclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/shielddivisor) : -1;
7545
7546 145 break;
7547
7548 case e7tUNJINX:
7549
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 199 times.
256 if (dm8&e8tSWORD)
7550 199 swordclk=0;
7551
7552
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 76 times.
256 if (dm8&e8tITEM)
7553 76 itemclk=0;
7554
7555
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if (dm8&e8tSHIELD)
7556 shieldjinxclk=0;
7557
7558 256 break;
7559
7560 case e7tTAKEMAGIC:
7561 5 game->change_dmagic(-dm8*game->get_magicdrainrate());
7562 5 break;
7563
7564 case e7tTAKERUPEES:
7565 21 game->change_drupy(-dm8);
7566 21 break;
7567
7568 case e7tDRUNK:
7569 6 drunkclk += dm8;
7570 6 break;
7571 }
7572 4681 verifyAWpn();
7573
2/2
✓ Branch 0 taken 4543 times.
✓ Branch 1 taken 138 times.
4681 if(dm7 >= e7tEATITEMS)
7574 {
7575 138 EatHero(hit2);
7576 138 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7577 138 action=none; FFCore.setHeroAction(none);
7578 138 }
7579 }
7580 4681 }
7581 9214 return 0;
7582 31136 }
7583
7584 515455 void HeroClass::addsparkle(int32_t wpn)
7585 {
7586 //return;
7587 515455 weapon *w = (weapon*)Lwpns.spr(wpn);
7588 515455 int32_t itemid = w->parentitem;
7589
7590
2/2
✓ Branch 0 taken 509694 times.
✓ Branch 1 taken 5761 times.
515455 if(itemid<0)
7591 5761 return;
7592
7593 509694 int32_t itemtype = itemsbuf[itemid].family;
7594
7595
4/4
✓ Branch 0 taken 509621 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 127430 times.
✓ Branch 3 taken 382191 times.
509694 if(itemtype!=itype_cbyrna && frame%4)
7596 382191 return;
7597
7598
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127430 times.
127503 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7599
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127430 times.
127503 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7600 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7601
5/8
✓ Branch 0 taken 37818 times.
✓ Branch 1 taken 89685 times.
✓ Branch 2 taken 69395 times.
✓ Branch 3 taken 20290 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37818 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127503 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7602 127503 int32_t direction=w->dir;
7603
7604
2/2
✓ Branch 0 taken 69395 times.
✓ Branch 1 taken 58108 times.
127503 if(sparkle_type)
7605 {
7606 58108 int32_t h=0;
7607 58108 int32_t v=0;
7608
7609
6/6
✓ Branch 0 taken 45868 times.
✓ Branch 1 taken 12240 times.
✓ Branch 2 taken 40776 times.
✓ Branch 3 taken 5092 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 33075 times.
58108 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7610 {
7611 25033 h=-1;
7612 25033 }
7613
7614
6/6
✓ Branch 0 taken 46277 times.
✓ Branch 1 taken 11831 times.
✓ Branch 2 taken 39583 times.
✓ Branch 3 taken 6694 times.
✓ Branch 4 taken 5719 times.
✓ Branch 5 taken 33864 times.
58108 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7615 {
7616 24244 h=1;
7617 24244 }
7618
7619
6/6
✓ Branch 0 taken 54209 times.
✓ Branch 1 taken 3899 times.
✓ Branch 2 taken 48490 times.
✓ Branch 3 taken 5719 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 40789 times.
58108 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7620 {
7621 17319 v=-1;
7622 17319 }
7623
7624
6/6
✓ Branch 0 taken 53176 times.
✓ Branch 1 taken 4932 times.
✓ Branch 2 taken 46482 times.
✓ Branch 3 taken 6694 times.
✓ Branch 4 taken 5092 times.
✓ Branch 5 taken 41390 times.
58108 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7625 {
7626 16718 v=1;
7627 16718 }
7628
7629 // Damaging boomerang sparkle?
7630
3/4
✓ Branch 0 taken 20290 times.
✓ Branch 1 taken 37818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20290 times.
58108 if(wpn3 && itemtype==itype_brang)
7631 {
7632 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7633 // whatever it just bounced off of if it's shielded from that direction.
7634
6/6
✓ Branch 0 taken 13240 times.
✓ Branch 1 taken 7050 times.
✓ Branch 2 taken 12389 times.
✓ Branch 3 taken 851 times.
✓ Branch 4 taken 5382 times.
✓ Branch 5 taken 7007 times.
20290 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7635 7007 direction=oppositeDir[direction];
7636 20290 }
7637
4/4
✓ Branch 0 taken 53757 times.
✓ Branch 1 taken 4351 times.
✓ Branch 2 taken 24015 times.
✓ Branch 3 taken 29742 times.
58108 if(itemtype==itype_brang && get_qr(qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7638
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 58035 times.
58108 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7639
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 58035 times.
58108 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7640
5/10
✓ Branch 0 taken 58108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58108 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58108 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58108 times.
✗ Branch 9 not taken.
58108 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7641 58108 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7642 58108 }
7643 515455 }
7644
7645 // For wPhantoms
7646 7410 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7647 {
7648
2/2
✓ Branch 0 taken 5586 times.
✓ Branch 1 taken 1824 times.
7410 if(frame%4) return;
7649
7650 1824 int32_t arrow = -1;
7651
7652
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 10041 times.
11561 for(int32_t i=0; i<Lwpns.Count(); i++)
7653 {
7654 10041 weapon *w = (weapon*)Lwpns.spr(i);
7655
7656
4/4
✓ Branch 0 taken 6249 times.
✓ Branch 1 taken 3792 times.
✓ Branch 2 taken 5945 times.
✓ Branch 3 taken 304 times.
10041 if(w->id == wPhantom && w->type == type1)
7657 {
7658 304 arrow = i;
7659 304 break;
7660 }
7661 9737 }
7662
7663
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1520 times.
1824 if(arrow==-1)
7664 {
7665 1520 return;
7666 }
7667
7668 304 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7669 304 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7670
6/12
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 304 times.
✗ Branch 11 not taken.
304 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7671 7410 }
7672
7673 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7674 14307770 void HeroClass::PhantomsCleanup()
7675 {
7676
2/2
✓ Branch 0 taken 5097860 times.
✓ Branch 1 taken 14307770 times.
19405630 for(int32_t i=0; i<Lwpns.Count(); i++)
7677 {
7678 5097860 weapon *w = ((weapon *)Lwpns.spr(i));
7679
3/4
✓ Branch 0 taken 4869 times.
✓ Branch 1 taken 5092991 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4869 times.
5097860 if ( w->id == wPhantom && !w->isScriptGenerated() )
7680 {
7681
4/8
✓ Branch 0 taken 4869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4869 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4869 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4869 times.
4869 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7682 {
7683 Lwpns.remove(w);
7684 }
7685 4869 }
7686 5097860 }
7687 14307770 }
7688
7689 //Waitframe handler for refilling operations
7690 6288 static void do_refill_waitframe()
7691 {
7692 6288 put_passive_subscr(framebuf,0,0,game->should_show_time(),sspUP);
7693
1/2
✓ Branch 0 taken 6288 times.
✗ Branch 1 not taken.
6288 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7694 {
7695 script_drawing_commands.Clear();
7696 if(DMaps[cur_dmap].passive_sub_script != 0)
7697 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
7698
7699 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[cur_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
7700 {
7701 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
7702 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
7703 }
7704 do_script_draws(framebuf, origin_scr, 0, playing_field_offset);
7705 }
7706 6288 advanceframe(true);
7707 6288 }
7708 //Special handler if it's a "fairy revive"
7709 static void do_death_refill_waitframe()
7710 {
7711 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7712 //This script should be able to draw a 'fairy saving the player' animation -Em
7713 do_refill_waitframe();
7714 }
7715
7716 1 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7717 {
7718 1 int32_t found_unowned = -1;
7719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 for(int q = 0; q < MAXITEMS; ++q)
7720 {
7721
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
153 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7722 {
7723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_item(q))
7724 1 return q;
7725 if(unowned)
7726 found_unowned = q;
7727 }
7728 152 }
7729 return found_unowned;
7730 1 }
7731
7732 int32_t getPushDir(int32_t flag)
7733 {
7734 switch(flag)
7735 {
7736 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7737 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7738 case mfPUSHUINS:
7739 return up;
7740 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7741 return down;
7742 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7743 case mfPUSHLRINS: case mfPUSHLINS:
7744 return left;
7745 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7746 return right;
7747 }
7748 return -1;
7749 }
7750
7751 void post_item_collect();
7752
7753 14309408 bool HeroClass::handle_portal_collide(portal* p)
7754 {
7755
1/2
✓ Branch 0 taken 14309408 times.
✗ Branch 1 not taken.
14309408 if(!p) return false;
7756 14309408 p->animate(0);
7757
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14309408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14309408 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7758 14309408 return false;
7759 if(abs(x - p->x) < 12
7760 && abs(y - p->y) < 12)
7761 {
7762 if(p->prox_active)
7763 {
7764 //Store some values to restore if 'warp fails'
7765 int32_t tLastEntrance = lastentrance,
7766 tLastEntranceDMap = lastentrance_dmap,
7767 tContScr = game->get_continue_scrn(),
7768 tContDMap = game->get_continue_dmap();
7769 int32_t sourcescr = cur_screen, sourcedmap = cur_dmap;
7770 zfix tx = x, ty = y, tz = z;
7771 x = p->x;
7772 y = p->y;
7773
7774 int32_t weff = p->weffect,
7775 wsfx = p->wsfx;
7776
7777 int32_t savep = p->saved_data;
7778 //After this line, 'p' becomes INVALID!
7779 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7780 -1, -1, weff, wsfx, 0, -1);
7781
7782 if(mirrorBonk()) //Invalid landing, warp back!
7783 {
7784 action = none; FFCore.setHeroAction(none);
7785 lastentrance = tLastEntrance;
7786 lastentrance_dmap = tLastEntranceDMap;
7787 game->set_continue_scrn(tContScr);
7788 game->set_continue_dmap(tContDMap);
7789 x = tx;
7790 y = ty;
7791 z = tz;
7792 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7793 wsfx, 0, -1);
7794 handle_portal_prox(&mirror_portal);
7795 portals.forEach([&](sprite& p)
7796 {
7797 handle_portal_prox((portal*)&p);
7798 return false;
7799 });
7800 }
7801 else game->clear_portal(savep); //Remove portal once used
7802 return true;
7803 }
7804 }
7805 else p->prox_active = true;
7806 return false;
7807 14309408 }
7808 145 void HeroClass::handle_portal_prox(portal* p)
7809 {
7810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(!p) return;
7811
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 23 times.
145 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7812 145 }
7813 // returns true when game over
7814 42177022 bool HeroClass::animate(int32_t)
7815 {
7816 42177022 update_heroscr();
7817
7818 42177022 int32_t lsave=0;
7819
1/2
✓ Branch 0 taken 42177022 times.
✗ Branch 1 not taken.
42177022 if(immortal > 0)
7820 --immortal;
7821 42177022 prompt_combo = 0;
7822
2/2
✓ Branch 0 taken 27868237 times.
✓ Branch 1 taken 14308785 times.
42177022 if (onpassivedmg)
7823 {
7824 27868237 onpassivedmg=false;
7825 27868237 }
7826
2/2
✓ Branch 0 taken 14308780 times.
✓ Branch 1 taken 5 times.
14308785 else if (damageovertimeclk)
7827 {
7828 5 damageovertimeclk = 0;
7829 5 }
7830
7831
2/2
✓ Branch 0 taken 42166616 times.
✓ Branch 1 taken 10406 times.
42177022 if(lift_wpn)
7832 {
7833 10406 auto oldid = lift_wpn->id;
7834
2/2
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 9483 times.
10406 switch(lift_wpn->id)
7835 {
7836 case wLitBomb:
7837 case wBomb:
7838 case wLitSBomb:
7839 case wSBomb:
7840
2/4
✓ Branch 0 taken 923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 923 times.
923 if(lift_wpn->misc && get_qr(qr_HELD_BOMBS_EXPLODE)) //timed fuse
7841 {
7842 923 lift_wpn->limited_animate();
7843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 923 times.
923 if(lift_wpn->id != oldid)
7844 {
7845 lift_wpn->moveflags &= ~move_obeys_grav;
7846 drop_liftwpn();
7847 goto heroanimate_skip_liftwpn;
7848 }
7849 923 ++lift_wpn->clk;
7850 923 }
7851 923 break;
7852 }
7853
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(lift_wpn->dead>0)
7854 --lift_wpn->dead;
7855
7856
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(get_qr(qr_LIFTED_WEAPONS_RUN_SCRIPTS))
7857 lift_wpn->run_script(MODE_NORMAL);
7858
7859
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(lift_wpn->dead==0)
7860 {
7861 if(lift_wpn->death_spawnitem > -1)
7862 {
7863 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7864 itm->fakez = lift_wpn->fakez;
7865 items.add(itm);
7866 }
7867 if(lift_wpn->death_spawndropset > -1)
7868 {
7869 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7870 if(itid > -1)
7871 {
7872 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7873 itm->fakez = lift_wpn->fakez;
7874 itm->from_dropset = lift_wpn->death_spawndropset;
7875 items.add(itm);
7876 }
7877 }
7878 switch(lift_wpn->death_sprite)
7879 {
7880 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7881 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7882 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7883 default:
7884 if(lift_wpn->death_sprite < 0) break;
7885 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dCOMBOSPRITE, 0, lift_wpn->death_sprite));
7886 }
7887 if(lift_wpn->death_sfx > 0)
7888 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7889 delete lift_wpn;
7890 lift_wpn = nullptr;
7891 }
7892 heroanimate_skip_liftwpn:;
7893 10406 }
7894
7895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42177022 times.
42177022 if(cheats_execute_goto)
7896 {
7897 setpit();
7898 dowarp(hero_scr, 3, 0);
7899 cheats_execute_goto=false;
7900 solid_update(false);
7901 return false;
7902 }
7903
7904
1/2
✓ Branch 0 taken 42177022 times.
✗ Branch 1 not taken.
42177022 if(cheats_execute_light)
7905 {
7906 toggle_lights(pal_litOVERRIDE); //Forcibly set permLit, overriding its current setting
7907 cheats_execute_light = false;
7908 }
7909
7910
3/4
✓ Branch 0 taken 14309408 times.
✓ Branch 1 taken 27867614 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14309408 times.
42177022 if(action!=climbcovertop&&action!=climbcoverbottom)
7911 {
7912 14309408 climb_cover_x=-1000;
7913 14309408 climb_cover_y=-1000;
7914 14309408 }
7915
7916 42177022 handle_portal_collide(&mirror_portal);
7917
1/2
✓ Branch 0 taken 42177022 times.
✗ Branch 1 not taken.
42177022 portals.forEach([&](sprite& p)
7918 {
7919 return handle_portal_collide((portal*)&p);
7920 });
7921
7922
3/4
✓ Branch 0 taken 14292670 times.
✓ Branch 1 taken 27884352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14292670 times.
42177022 if(z<=8&&fakez<=8) //Tall Grass
7923 {
7924 14292670 int maxlyr = get_qr(qr_BUSHESONLAYERS1AND2) ? 2 : 0;
7925
2/2
✓ Branch 0 taken 632362 times.
✓ Branch 1 taken 13660308 times.
14292670 if (get_qr(qr_GRASS_SENSITIVE))
7926 {
7927 632362 bool g1 = false, g2 = false, g3 = false, g4 = false;
7928
2/2
✓ Branch 0 taken 1814024 times.
✓ Branch 1 taken 632362 times.
2446386 for(int q = maxlyr; q >= 0; --q)
7929 {
7930
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 1811742 times.
1814024 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+15)].type);
7931
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 1811773 times.
1814024 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+15)].type);
7932
2/2
✓ Branch 0 taken 2323 times.
✓ Branch 1 taken 1811701 times.
1814024 g3 = g3 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+9)].type);
7933
2/2
✓ Branch 0 taken 2350 times.
✓ Branch 1 taken 1811674 times.
1814024 g4 = g4 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+9)].type);
7934 1814024 }
7935
8/8
✓ Branch 0 taken 8260 times.
✓ Branch 1 taken 624102 times.
✓ Branch 2 taken 7135 times.
✓ Branch 3 taken 1125 times.
✓ Branch 4 taken 6227 times.
✓ Branch 5 taken 908 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 6165 times.
632362 if(g1 && g2 && g3 && g4)
7936 {
7937 6165 int grasscid = 0;
7938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16508 times.
16508 for(int q = maxlyr; q >= 0; --q)
7939 {
7940 16508 int cid = MAPCOMBO2(q-1,x+8,y+12);
7941
4/4
✓ Branch 0 taken 7637 times.
✓ Branch 1 taken 8871 times.
✓ Branch 2 taken 1472 times.
✓ Branch 3 taken 6165 times.
16508 if(cid > 0 && isGrassType(combobuf[cid].type))
7942 {
7943 6165 grasscid = cid;
7944 6165 break;
7945 }
7946 10343 }
7947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6165 times.
6165 if(grasscid)
7948 {
7949 6165 newcombo const& cmb = combobuf[grasscid];
7950
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 1162 times.
6165 if(decorations.idCount(dTALLGRASS)==0)
7951 {
7952
3/6
✓ Branch 0 taken 1162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
1162 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7953 1162 }
7954 6165 int32_t thesfx = cmb.attribytes[3];
7955
2/2
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 4130 times.
6165 if (action==walking)
7956 4130 sfx_no_repeat(thesfx,pan((int32_t)x));
7957 6165 }
7958 6165 }
7959 632362 }
7960 else
7961 {
7962 13660308 bool g1 = false, g2 = false;
7963
2/2
✓ Branch 0 taken 14066920 times.
✓ Branch 1 taken 13660308 times.
27727228 for(int q = maxlyr; q >= 0; --q)
7964 {
7965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14066920 times.
14066920 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x,y+15)].type);
7966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14066920 times.
14066920 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+15,y+15)].type);
7967 14066920 }
7968
4/4
✓ Branch 0 taken 141631 times.
✓ Branch 1 taken 13518677 times.
✓ Branch 2 taken 30796 times.
✓ Branch 3 taken 110835 times.
13660308 if(g1 && g2)
7969 {
7970 110835 int grasscid = 0;
7971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124915 times.
124915 for(int q = maxlyr; q >= 0; --q)
7972 {
7973 124915 int cid = MAPCOMBO2(q-1,x+8,y+15);
7974
3/4
✓ Branch 0 taken 110835 times.
✓ Branch 1 taken 14080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110835 times.
124915 if(cid > 0 && isGrassType(combobuf[cid].type))
7975 {
7976 110835 grasscid = cid;
7977 110835 break;
7978 }
7979 14080 }
7980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110835 times.
110835 if(grasscid)
7981 {
7982 110835 newcombo const& cmb = combobuf[grasscid];
7983
2/2
✓ Branch 0 taken 108195 times.
✓ Branch 1 taken 2640 times.
110835 if(decorations.idCount(dTALLGRASS)==0)
7984 {
7985
3/6
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2640 times.
✗ Branch 5 not taken.
2640 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7986 2640 }
7987 110835 int32_t thesfx = cmb.attribytes[3];
7988
2/2
✓ Branch 0 taken 39735 times.
✓ Branch 1 taken 71100 times.
110835 if (action==walking )
7989 71100 sfx_no_repeat(thesfx,pan((int32_t)x));
7990 110835 }
7991 110835 }
7992 }
7993 14292670 }
7994
3/4
✓ Branch 0 taken 14290285 times.
✓ Branch 1 taken 27886737 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14290285 times.
42177022 if(z==0 && fakez==0) //Shallow Water / Custom Walk SFX
7995 {
7996
2/2
✓ Branch 0 taken 1177671 times.
✓ Branch 1 taken 13112614 times.
14290285 if (get_qr(qr_SHALLOW_SENSITIVE))
7997 {
7998
18/22
✓ Branch 0 taken 1169616 times.
✓ Branch 1 taken 8055 times.
✓ Branch 2 taken 1169616 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1165360 times.
✓ Branch 5 taken 4256 times.
✓ Branch 6 taken 1165104 times.
✓ Branch 7 taken 256 times.
✓ Branch 8 taken 1165104 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1165104 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1161534 times.
✓ Branch 13 taken 3570 times.
✓ Branch 14 taken 1161534 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1161501 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 1151090 times.
✓ Branch 19 taken 10411 times.
✓ Branch 20 taken 1547 times.
✓ Branch 21 taken 1149543 times.
1177671 if (action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7999 {
8000 1149543 bool b1 = iswaterex_z3(FFORCOMBO(x+11,y+15), -1, x+11, y+15, false, false, true, true);
8001 1149543 bool b2 = iswaterex_z3(FFORCOMBO(x+4,y+15), -1, x+4, y+15, false, false, true, true);
8002 1149543 bool b3 = iswaterex_z3(FFORCOMBO(x+11,y+9), -1, x+11, y+9, false, false, true, true);
8003 1149543 bool b4 = iswaterex_z3(FFORCOMBO(x+4,y+9), -1, x+4, y+9, false, false, true, true);
8004
8005
8/8
✓ Branch 0 taken 60555 times.
✓ Branch 1 taken 1088988 times.
✓ Branch 2 taken 56317 times.
✓ Branch 3 taken 4238 times.
✓ Branch 4 taken 52954 times.
✓ Branch 5 taken 3363 times.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 52808 times.
1149543 if (b1 && b2 && b3 && b4)
8006 {
8007 52808 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
8008 52808 auto combined_handle = get_combined_handle_for_world_xy(watercheck_x, watercheck_y, 0);
8009 52808 int waterid = combined_handle.data();
8010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8011 52808 waterid = iswaterex_z3(waterid, -1, watercheck_x,watercheck_y, false, false, true, true);
8012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8013 {
8014 52808 newcombo const& watercmb = combobuf[waterid];
8015 52808 auto ripplesprite = watercmb.attribytes[6];
8016
2/2
✓ Branch 0 taken 52361 times.
✓ Branch 1 taken 447 times.
52808 if(decorations.idCount(dRIPPLES)==0)
8017
3/6
✓ Branch 0 taken 447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 447 times.
✗ Branch 5 not taken.
447 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8018
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 52185 times.
52808 if (watercmb.usrflags&cflag2)
8019 {
8020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
623 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
8021 {
8022 623 onpassivedmg = true;
8023
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
623 if (!damageovertimeclk)
8024 {
8025 314 int32_t curhp = game->get_life();
8026 314 auto dmg = watercmb.attributes[1]/10000L;
8027 314 auto hitsfx = watercmb.attributes[2]/10000L;
8028
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
8029
8030
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
314 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
8031 314 hitsfx = 0;
8032
8033 314 std::vector<int32_t> &ev = FFCore.eventData;
8034 314 ev.clear();
8035 314 ev.push_back(-dmg*10000);
8036 314 ev.push_back(-1*10000);
8037 314 ev.push_back(0);
8038 314 ev.push_back(0);
8039 314 ev.push_back(48*10000);
8040 314 ev.push_back(ZSD_COMBODATA*10000);
8041 314 ev.push_back(waterid);
8042 314 ev.push_back((combined_handle.is_ffc() ? ZSD_FFC : ZSD_COMBOPOS)*10000);
8043 314 ev.push_back(combined_handle.id()*10000);
8044
8045 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
8046
8047
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(watercmb.usrflags & cflag5)
8048 ev[0] = ringpower(ev[0]/10000) * 10000;
8049
8050 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
8051 314 dmg = -ev[0]/10000;
8052
8053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if(!ev[2]) //nullify
8054 {
8055 314 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
8056
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitsfx)
8057 sfx(hitsfx);
8058
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitstun)
8059 {
8060 hclk = ev[4]/10000;
8061 hitdir = ev[1]/10000;
8062 action = gothit; FFCore.setHeroAction(gothit);
8063 check_on_hit();
8064 }
8065 314 }
8066 314 }
8067
1/2
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
623 if (watercmb.attribytes[1] > 0)
8068 {
8069
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
623 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
8070 309 else --damageovertimeclk;
8071 623 }
8072 else damageovertimeclk = 0;
8073 623 }
8074 else damageovertimeclk = 0;
8075 623 }
8076 52185 else damageovertimeclk = 0;
8077 52808 int32_t thesfx = watercmb.attribytes[0];
8078
4/4
✓ Branch 0 taken 51858 times.
✓ Branch 1 taken 950 times.
✓ Branch 2 taken 46233 times.
✓ Branch 3 taken 5625 times.
52808 if (watercmb.type != cSHALLOWWATER || !get_qr(qr_OLD_SHALLOW_SFX))
8079 {
8080 6575 thesfx = watercmb.attribytes[5];
8081 6575 }
8082
2/2
✓ Branch 0 taken 28715 times.
✓ Branch 1 taken 24093 times.
52808 if (action==walking)
8083 24093 sfx_no_repeat(thesfx,pan((int32_t)x));
8084 52808 }
8085 52808 }
8086 1149543 }
8087 1177671 }
8088 else
8089 {
8090
4/4
✓ Branch 0 taken 12956578 times.
✓ Branch 1 taken 156036 times.
✓ Branch 2 taken 12969911 times.
✓ Branch 3 taken 142703 times.
13112614 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER))
8091 {
8092 142703 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
8093 142703 auto ripplesprite = combobuf[watercheck].attribytes[6];
8094
2/2
✓ Branch 0 taken 141287 times.
✓ Branch 1 taken 1416 times.
142703 if(decorations.idCount(dRIPPLES)==0)
8095 {
8096
3/6
✓ Branch 0 taken 1416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1416 times.
✗ Branch 5 not taken.
1416 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8097 1416 }
8098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142703 times.
142703 if (combobuf[watercheck].usrflags&cflag2)
8099 {
8100 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
8101 {
8102 onpassivedmg = true;
8103 if (!damageovertimeclk)
8104 {
8105 int32_t curhp = game->get_life();
8106 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
8107 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
8108 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
8109 }
8110 if (combobuf[watercheck].attribytes[1] > 0)
8111 {
8112 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
8113 else --damageovertimeclk;
8114 }
8115 else damageovertimeclk = 0;
8116 }
8117 else damageovertimeclk = 0;
8118 }
8119 142703 else damageovertimeclk = 0;
8120 142703 int32_t thesfx = combobuf[watercheck].attribytes[0];
8121
2/2
✓ Branch 0 taken 53531 times.
✓ Branch 1 taken 89172 times.
142703 if (action==walking )
8122 89172 sfx_no_repeat(thesfx,pan((int32_t)x));
8123 142703 }
8124 }
8125
8126 14290285 auto rpos = COMBOPOS_REGION_B(x+8,y+(sideview_mode()?16:12));
8127
2/2
✓ Branch 0 taken 14289131 times.
✓ Branch 1 taken 100025071 times.
114314202 for(int q = 0; q < 7; ++q)
8128 {
8129
2/2
✓ Branch 0 taken 1154 times.
✓ Branch 1 taken 100023917 times.
100025071 if (rpos == rpos_t::None)
8130 1154 break;
8131
8132 100023917 auto rpos_handle = get_rpos_handle(rpos, q);
8133 100023917 auto& cmb = rpos_handle.combo();
8134
2/2
✓ Branch 0 taken 53042066 times.
✓ Branch 1 taken 46981851 times.
100023917 byte csfx = action == walking ? cmb.sfx_walking : cmb.sfx_standing;
8135
2/2
✓ Branch 0 taken 53042066 times.
✓ Branch 1 taken 46981851 times.
100023917 byte cspr = action == walking ? cmb.spr_walking : cmb.spr_standing;
8136
2/2
✓ Branch 0 taken 100014293 times.
✓ Branch 1 taken 9624 times.
100023917 if(csfx)
8137 9624 sfx_no_repeat(csfx);
8138 100023917 auto indx = decorations.idFirst(dCUSTOMWALK);
8139
1/2
✓ Branch 0 taken 100023917 times.
✗ Branch 1 not taken.
100023917 if(cspr)
8140 {
8141 if(indx < 0)
8142 {
8143 if(decorations.add(new customWalkSprite(x, y, dCUSTOMWALK, 0, -1)))
8144 indx = decorations.Count()-1;
8145 }
8146 if(indx > -1)
8147 {
8148 if(customWalkSprite* spr = dynamic_cast<customWalkSprite*>(decorations.spr(indx)))
8149 spr->run_sprite(cspr);
8150 }
8151 }
8152 100023917 }
8153 14290285 }
8154
8155
2/2
✓ Branch 0 taken 42176597 times.
✓ Branch 1 taken 425 times.
42177022 if(stomping)
8156 425 stomping = false;
8157
8158
2/2
✓ Branch 0 taken 42176711 times.
✓ Branch 1 taken 311 times.
42177022 if(getOnSideviewLadder())
8159 {
8160
4/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311 times.
311 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
8161 {
8162 setOnSideviewLadder(false);
8163 }
8164
2/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 311 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
311 else if(CANFORCEFACEUP)
8165 {
8166 setDir(up);
8167 }
8168 311 }
8169
8170
7/8
✓ Branch 0 taken 14291054 times.
✓ Branch 1 taken 27885968 times.
✓ Branch 2 taken 14284942 times.
✓ Branch 3 taken 6112 times.
✓ Branch 4 taken 14284686 times.
✓ Branch 5 taken 256 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 14284686 times.
42177022 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
8171 {
8172
2/2
✓ Branch 0 taken 13231508 times.
✓ Branch 1 taken 1053178 times.
14284686 if(!get_qr(qr_OLD_CHEST_COLLISION))
8173 {
8174 1053178 checkchest(cCHEST);
8175 1053178 checkchest(cLOCKEDCHEST);
8176 1053178 checkchest(cBOSSCHEST);
8177 1053178 }
8178
2/2
✓ Branch 0 taken 13717421 times.
✓ Branch 1 taken 567265 times.
14284686 if(!get_qr(qr_OLD_LOCKBLOCK_COLLISION))
8179 {
8180 567265 checkchest(cLOCKBLOCK);
8181 567265 checkchest(cBOSSLOCKBLOCK);
8182 567265 }
8183 14284686 }
8184 42177022 checksigns();
8185 42177022 checkgenpush();
8186
8187
4/4
✓ Branch 0 taken 13527416 times.
✓ Branch 1 taken 28649606 times.
✓ Branch 2 taken 13524301 times.
✓ Branch 3 taken 3115 times.
42177022 if(isStanding(true) && fall == 0)
8188 {
8189
1/2
✓ Branch 0 taken 13524301 times.
✗ Branch 1 not taken.
13524301 if(extra_jump_count > 0)
8190 extra_jump_count = 0;
8191 13524301 coyotetime = 0;
8192 13524301 }
8193
2/2
✓ Branch 0 taken 27882014 times.
✓ Branch 1 taken 770707 times.
28652721 else if(coyotetime < 65535)
8194 {
8195 770707 ++coyotetime;
8196 770707 }
8197
2/2
✓ Branch 0 taken 42117615 times.
✓ Branch 1 taken 59407 times.
42177022 if(can_use_item(itype_hoverboots,i_hoverboots))
8198 {
8199 59407 int32_t hoverid = current_item_id(itype_hoverboots);
8200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59407 times.
59407 if(!(itemsbuf[hoverid].flags & item_flag1))
8201 {
8202
1/2
✓ Branch 0 taken 59407 times.
✗ Branch 1 not taken.
59407 if(hoverclk < 0) hoverclk = 0;
8203 59407 hoverflags &= ~HOV_OUT;
8204 59407 }
8205 59407 }
8206 42177022 bool platformfell2 = false;
8207 42177022 int32_t gravity3 = (zinit.gravity/100);
8208 42177022 int32_t termv = (zinit.terminalv);
8209 42177022 int32_t rocs = getRocsPressed();
8210
2/2
✓ Branch 0 taken 5577 times.
✓ Branch 1 taken 42171445 times.
42177022 if (rocs != -1)
8211 {
8212 5577 itemdata const& itm = itemsbuf[rocs];
8213
1/2
✓ Branch 0 taken 5577 times.
✗ Branch 1 not taken.
5577 if (itm.flags & item_flag2)
8214 {
8215 if ((!(itm.flags & item_flag3) || fall < 0) &&
8216 (!(itm.flags & item_flag4) || fall > 0)) gravity3 = itm.misc3;
8217 }
8218
1/2
✓ Branch 0 taken 5577 times.
✗ Branch 1 not taken.
5577 if (itm.flags & item_flag5)
8219 {
8220 termv = itm.misc4;
8221 if (fall > termv) fall = termv;
8222 }
8223 5577 }
8224
2/2
✓ Branch 0 taken 319044 times.
✓ Branch 1 taken 41857978 times.
42177022 if(sideview_mode()) // Sideview gravity
8225 {
8226 //Handle falling through a platform
8227 319044 bool platformfell = false;
8228
3/4
✓ Branch 0 taken 161041 times.
✓ Branch 1 taken 158003 times.
✓ Branch 2 taken 161041 times.
✗ Branch 3 not taken.
319044 if (on_sideview_solid_oldpos(this,true,3) && !on_sideview_solid_oldpos(this,false,3))
8229 {
8230 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
8231 y+=1; //Fall down a pixel instantly, through the platform.
8232 if(fall < 0) fall = 0;
8233 if(jumping < 0) jumping = 0;
8234 platformfell2 = true;
8235 }
8236 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
8237
2/2
✓ Branch 0 taken 313554 times.
✓ Branch 1 taken 5490 times.
319044 if(!get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8238 {
8239
14/22
✓ Branch 0 taken 4180 times.
✓ Branch 1 taken 1310 times.
✓ Branch 2 taken 1310 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1310 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1310 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1310 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 1302 times.
✓ Branch 12 taken 1302 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1302 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1302 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1302 times.
✓ Branch 20 taken 5482 times.
✓ Branch 21 taken 8 times.
6800 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,STANDING_Z_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,STANDING_Z_STATE)
8240
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1302 times.
1302 || ((y+(fall/100)<=0) &&
8241 // Extra checks if Smart Screen Scrolling is enabled
8242 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8243 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up)))))))
8244 {
8245 8 fall = jumping = 0; // Bumped his head
8246
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8247 y -= y.getInt()%8; //fix coords
8248 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8250 {
8251 8 checkdamagecombos(x+4, x+12, y-1, y-1);
8252 8 }
8253 8 }
8254 5490 }
8255 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
8256
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 319044 times.
✓ Branch 2 taken 319044 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319044 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319044 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319044 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319044 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 311 times.
✓ Branch 13 taken 318733 times.
319044 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
8257 {
8258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318733 times.
318733 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
8259 318733 falling_oldy = y; // Stomp Boots-related variable
8260
8261
5/8
✓ Branch 0 taken 60726 times.
✓ Branch 1 taken 258007 times.
✓ Branch 2 taken 60726 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60726 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 318733 times.
✗ Branch 7 not taken.
318733 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (TRUNCATE_TILE(y.getInt()+ydiff+15) != TRUNCATE_TILE(y.getInt()+15)) && !platform_fallthrough())
8262 {
8263 ydiff -= (y.getInt()+ydiff)%16;
8264 }
8265
4/4
✓ Branch 0 taken 87354 times.
✓ Branch 1 taken 231379 times.
✓ Branch 2 taken 84656 times.
✓ Branch 3 taken 2698 times.
318733 if(ydiff && !get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8266 {
8267
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 1146 times.
2698 if(ydiff > 0)
8268 {
8269
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 3277 times.
4788 for(auto q = 0; q < ydiff; ++q)
8270 {
8271
2/2
✓ Branch 0 taken 3236 times.
✓ Branch 1 taken 41 times.
3277 if(on_sideview_solid_oldpos(this, false, 0, 0, q))
8272 {
8273 41 ydiff = q;
8274 41 break;
8275 }
8276 3236 }
8277 1552 }
8278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1146 times.
1146 else if(ydiff < 0)
8279 {
8280
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 2639 times.
3785 for(auto q = 0; q > ydiff; --q)
8281 {
8282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2639 times.
2639 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
8283
1/2
✓ Branch 0 taken 2639 times.
✗ Branch 1 not taken.
2639 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
8284 {
8285 ydiff = q;
8286 break;
8287 }
8288 2639 }
8289 1146 }
8290 2698 }
8291 318733 y+=ydiff;
8292 318733 hs_starty+=ydiff;
8293
8294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318733 times.
318733 for(int32_t j=0; j<chainlinks.Count(); j++)
8295 {
8296 chainlinks.spr(j)->y+=ydiff;
8297 }
8298
8299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318733 times.
318733 if(Lwpns.idFirst(wHookshot)>-1)
8300 {
8301 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
8302 }
8303
8304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318733 times.
318733 if(Lwpns.idFirst(wHSHandle)>-1)
8305 {
8306 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
8307 }
8308 318733 }
8309
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
311 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
8310 {
8311 fall = hoverclk = jumping = 0;
8312 inair = false;
8313 hoverflags = 0;
8314 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
8315 {
8316 WalkflagInfo info;
8317 if (game->get_watergrav()<0)
8318 {
8319 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
8320 execute(info);
8321 }
8322 else
8323 {
8324 info = walkflag(x,y+15+2,2,down);
8325 execute(info);
8326 }
8327
8328 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)-2), -1, x, y+8-(bigHitbox*8)-2, true, false)))
8329 {
8330 y += (game->get_watergrav()/10000.0);
8331 }
8332 }
8333 }
8334 // Stop hovering/falling if you land on something.
8335 319044 bool needFall = false;
8336
6/8
✓ Branch 0 taken 157365 times.
✓ Branch 1 taken 161679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319044 times.
✓ Branch 4 taken 161990 times.
✓ Branch 5 taken 157054 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 161990 times.
319044 if((on_sideview_solid_oldpos(this) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
8337 {
8338 161990 stop_item_sfx(itype_hoverboots);
8339 161990 auto oldfall = fall;
8340 161990 fall = hoverclk = jumping = 0;
8341
2/2
✓ Branch 0 taken 159688 times.
✓ Branch 1 taken 2302 times.
161990 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8342 {
8343
4/6
✓ Branch 0 taken 159688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 156423 times.
✓ Branch 3 taken 3265 times.
✓ Branch 4 taken 156423 times.
✗ Branch 5 not taken.
159688 if(!getOnSideviewLadder() && (oldfall > 0 || get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8344 {
8345 159688 y.doFloor();
8346 159688 y-=(int32_t)y%8; //fix position
8347 159688 }
8348
2/2
✓ Branch 0 taken 156423 times.
✓ Branch 1 taken 3265 times.
159688 if(oldfall > 0)
8349 3265 land_on_ground();
8350 159688 }
8351 else
8352 {
8353 2302 snap_platform();
8354
2/2
✓ Branch 0 taken 2227 times.
✓ Branch 1 taken 75 times.
2302 if(oldfall > 0)
8355 75 land_on_ground();
8356 }
8357 161990 inair = false;
8358 161990 hoverflags = 0;
8359
8360
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 161976 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
161990 if(y>=world_h-16 && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) // Landed on the bottommost screen.
8361 14 y = world_h-16;
8362 161990 }
8363 // Stop hovering if you press down.
8364
3/6
✓ Branch 0 taken 157054 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157054 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157054 times.
✗ Branch 5 not taken.
157054 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8365 {
8366 stop_item_sfx(itype_hoverboots);
8367 hoverclk = -hoverclk;
8368 reset_ladder();
8369 fall = gravity3;
8370 inair = false;
8371 }
8372
8/10
✓ Branch 0 taken 157054 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3579 times.
✓ Branch 3 taken 153475 times.
✓ Branch 4 taken 1340 times.
✓ Branch 5 taken 2239 times.
✓ Branch 6 taken 1340 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 344 times.
✓ Branch 9 taken 996 times.
157054 else if (hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
8373 {
8374 996 needFall = true;
8375
2/2
✓ Branch 0 taken 867 times.
✓ Branch 1 taken 129 times.
996 if (replay_version_check(0, 23))
8376 {
8377 867 zfix my = y + 4;
8378
2/2
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 2388 times.
3129 for (zfix ty = y + 1; ty < my; ++ty)
8379 {
8380
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 2262 times.
2388 if (on_sideview_solid_oldpos(this, false, 0, 0, ty-y))
8381 {
8382 126 y = ty;
8383
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8384 {
8385 if (!slopeid)
8386 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8387 onplatid = 1;
8388 }
8389 126 needFall = false;
8390 126 break;
8391 }
8392 2262 }
8393 867 }
8394 else
8395 {
8396 129 zfix dy = 0;
8397 129 bool landed = false;
8398
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
2322 dy = binary_search_zfix(0, 4, [&](zfix val, zfix& retval)
8399 {
8400
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2077 times.
2193 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
8401 {
8402 116 retval = val;
8403 116 landed = true;
8404 116 return BSEARCH_CONTINUE_TOWARD0;
8405 }
8406 2077 else return BSEARCH_CONTINUE_AWAY0;
8407 2193 });
8408
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 112 times.
129 if (dy)
8409 {
8410 112 push_move(0, dy);
8411 112 }
8412
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 112 times.
129 if (landed)
8413 {
8414
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 96 times.
112 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, false, true) < 0)
8415 {
8416
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 16 times.
96 if (!slopeid)
8417 16 slopeid = get_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y).get_info().slope();
8418 96 onplatid = 1;
8419 96 }
8420 112 needFall = false;
8421 112 }
8422 }
8423 996 }
8424 else
8425 {
8426 156058 needFall = true;
8427 }
8428 // Continue falling.
8429
8430
4/4
✓ Branch 0 taken 309693 times.
✓ Branch 1 taken 9351 times.
✓ Branch 2 taken 162228 times.
✓ Branch 3 taken 147465 times.
319044 if(fall <= termv && needFall)
8431 {
8432 147465 inair = true;
8433
3/4
✓ Branch 0 taken 56360 times.
✓ Branch 1 taken 91105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56360 times.
147465 if(fall != 0 || hoverclk>0)
8434 91105 jumping++;
8435
8436 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8437
2/2
✓ Branch 0 taken 144750 times.
✓ Branch 1 taken 2715 times.
147465 if(get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8438 {
8439
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144750 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144750 times.
✓ Branch 4 taken 144026 times.
✓ Branch 5 taken 724 times.
289500 if((_walkflag(x+4,y-(bigHitbox?9:1),0,STANDING_Z_STATE)
8440
4/4
✓ Branch 0 taken 138377 times.
✓ Branch 1 taken 6373 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 137254 times.
144750 || (y<=(bigHitbox?9:1) &&
8441 // Extra checks if Smart Screen Scrolling is enabled
8442
2/6
✓ Branch 0 taken 1123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1123 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1123 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8443 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up))))))
8444
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6373 && fall < 0)
8445 {
8446 724 fall = jumping = 0; // Bumped his head
8447
8448 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8449
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 110 times.
724 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8450 {
8451 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8452 110 }
8453 724 }
8454 144750 }
8455 else
8456 {
8457
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2715 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2715 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 2705 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2705 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2705 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2705 times.
✓ Branch 14 taken 2713 times.
✓ Branch 15 taken 2 times.
5430 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,STANDING_Z_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,STANDING_Z_STATE)
8458
2/4
✓ Branch 0 taken 2705 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2705 times.
2705 || ((y<=0) &&
8459 // Extra checks if Smart Screen Scrolling is enabled
8460 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8461 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up))))))
8462
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 && fall < 0)
8463 {
8464 2 fall = jumping = 0; // Bumped his head
8465 2 y -= y.getInt()%8; //fix coords
8466 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8468 {
8469 2 checkdamagecombos(x+4, x+12, y-1, y-1);
8470 2 }
8471 2 }
8472 }
8473
8474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147465 times.
147465 if(hoverclk > 0)
8475 {
8476 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8477 {
8478 --hoverclk;
8479 }
8480
8481 if(!hoverclk && !ladderx && !laddery)
8482 {
8483 fall += gravity3;
8484 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8485 }
8486 }
8487
5/12
✓ Branch 0 taken 105265 times.
✓ Branch 1 taken 42200 times.
✓ Branch 2 taken 57230 times.
✓ Branch 3 taken 48035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57230 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
147465 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8488 {
8489 int32_t itemid = current_item_id(itype_hoverboots);
8490 if(hoverclk < 0)
8491 hoverclk = -hoverclk;
8492 else
8493 {
8494 fall = jumping = 0;
8495 if(itemsbuf[itemid].misc1)
8496 hoverclk = itemsbuf[itemid].misc1;
8497 else
8498 {
8499 hoverclk = 1;
8500 hoverflags |= HOV_INF;
8501 }
8502
8503
8504 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8505 }
8506 if(itemsbuf[itemid].wpn)
8507 decorations.add(new dHover(x, y, dHOVER, 0));
8508 }
8509
4/8
✓ Branch 0 taken 147465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147465 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147465 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 147465 times.
147465 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8510 {
8511 147465 fall += gravity3;
8512
8513 147465 }
8514 147465 }
8515 319044 }
8516 else // Topdown gravity
8517 {
8518
4/4
✓ Branch 0 taken 27867616 times.
✓ Branch 1 taken 13990362 times.
✓ Branch 2 taken 13986904 times.
✓ Branch 3 taken 3458 times.
41857978 if (!(moveflags & move_no_fake_z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8519
4/4
✓ Branch 0 taken 27867616 times.
✓ Branch 1 taken 13990362 times.
✓ Branch 2 taken 13986904 times.
✓ Branch 3 taken 3458 times.
41857978 if (!(moveflags & move_no_real_z)) z-=fall/(spins && fall>0 ? 200:100);
8520
4/4
✓ Branch 0 taken 13971256 times.
✓ Branch 1 taken 27886722 times.
✓ Branch 2 taken 27905828 times.
✓ Branch 3 taken 41877084 times.
41857978 if(z>0||fakez>0)
8521 {
8522
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55792550 switch(action)
8523 {
8524 case swimming:
8525 {
8526 diveclk=0;
8527 action=walking; FFCore.setHeroAction(walking);
8528
8529 break;
8530 }
8531 case waterhold1:
8532 {
8533 action=landhold1; FFCore.setHeroAction(landhold1);
8534 break;
8535 }
8536
8537 case waterhold2:
8538 {
8539 action=landhold2; FFCore.setHeroAction(landhold2);
8540 break;
8541 }
8542
8543 default:
8544 19106 break;
8545 }
8546 19106 }
8547
8548
2/2
✓ Branch 0 taken 160887 times.
✓ Branch 1 taken 41896190 times.
42057077 for(int32_t j=0; j<chainlinks.Count(); j++)
8549 {
8550 160887 chainlinks.spr(j)->z=z;
8551 160887 chainlinks.spr(j)->fakez=fakez;
8552 160887 }
8553
8554
2/2
✓ Branch 0 taken 44964 times.
✓ Branch 1 taken 41851226 times.
41896190 if(Lwpns.idFirst(wHookshot)>-1)
8555 {
8556 44964 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8557 44964 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8558 44964 }
8559
8560
2/2
✓ Branch 0 taken 47398 times.
✓ Branch 1 taken 41848792 times.
41896190 if(Lwpns.idFirst(wHSHandle)>-1)
8561 {
8562 47398 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8563 47398 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8564 47398 }
8565
8566
3/4
✓ Branch 0 taken 13971256 times.
✓ Branch 1 taken 27924934 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13971256 times.
41896190 if(z<=0&&!(moveflags & move_no_real_z))
8567 {
8568 13971256 auto oldfall = fall;
8569 13971256 z = fall = 0;
8570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13971256 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13971256 if (fakez <= 0 || (moveflags & move_no_fake_z))
8571 {
8572
2/2
✓ Branch 0 taken 13970819 times.
✓ Branch 1 taken 437 times.
13971256 if(oldfall > 0)
8573 {
8574 437 land_on_ground();
8575
8576 437 stomping = true;
8577 437 }
8578 13971256 }
8579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13971256 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13971256 if (fakez <= 0 || (moveflags & move_no_fake_z))
8580 {
8581 13971256 jumping = 0;
8582
2/2
✓ Branch 0 taken 3926 times.
✓ Branch 1 taken 13967330 times.
13971256 if(check_pitslide(true) == -1)
8583 {
8584 13967330 hoverclk = 0;
8585 13967330 hoverflags = 0;
8586 13967330 }
8587
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
3926 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8588 {
8589
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8590 {
8591 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8592 }
8593 17 }
8594 13971256 }
8595 13971256 }
8596
3/4
✓ Branch 0 taken 19106 times.
✓ Branch 1 taken 27905828 times.
✓ Branch 2 taken 19106 times.
✗ Branch 3 not taken.
27924934 else if(fakez<=0&&!(moveflags & move_no_fake_z))
8597 {
8598 19106 auto oldfakefall = fakefall;
8599 19106 fakez = fakefall = 0;
8600
2/4
✓ Branch 0 taken 19106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19106 times.
19106 if (z <= 0 || (moveflags & move_no_real_z))
8601 {
8602 if(oldfakefall > 0)
8603 {
8604 land_on_ground();
8605
8606 stomping = true;
8607 }
8608 }
8609
2/4
✓ Branch 0 taken 19106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19106 times.
19106 if (z <= 0 || (moveflags & move_no_real_z))
8610 {
8611 jumping = 0;
8612 if(check_pitslide(true) == -1)
8613 {
8614 hoverclk = 0;
8615 hoverflags = 0;
8616 }
8617 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8618 {
8619 if(!--hoverclk)
8620 {
8621 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8622 }
8623 }
8624 }
8625 19106 }
8626
8/10
✓ Branch 0 taken 13989980 times.
✓ Branch 1 taken 27906210 times.
✓ Branch 2 taken 13989980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13952914 times.
✓ Branch 5 taken 37066 times.
✓ Branch 6 taken 13971638 times.
✓ Branch 7 taken 13971638 times.
✓ Branch 8 taken 13971638 times.
✗ Branch 9 not taken.
41896190 if(fall <= termv && !(moveflags & move_no_real_z) && z>0 || fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0)
8627 {
8628
4/6
✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 15674 times.
✓ Branch 2 taken 3050 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3050 times.
27924552 if(fall != 0 || fakefall != 0 || hoverclk>0)
8629 15674 jumping++;
8630
8631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18724 times.
18724 if(hoverclk > 0)
8632 {
8633 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8634 {
8635 --hoverclk;
8636 }
8637
8638 if(!hoverclk)
8639 {
8640 if (fall <= termv && !(moveflags & move_no_real_z) && z > 0) fall += gravity3;
8641 if (fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0) fakefall += gravity3;
8642 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8643 }
8644 }
8645
9/16
✓ Branch 0 taken 10894 times.
✓ Branch 1 taken 7830 times.
✓ Branch 2 taken 3135 times.
✓ Branch 3 taken 7759 times.
✓ Branch 4 taken 3135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15589 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 18724 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
18724 else if(((fall+(int32_t)(zinit.gravity / 100) > 0 && fall<=0 && !(moveflags & move_no_real_z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & move_no_fake_z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8646 {
8647 if(hoverclk < 0)
8648 hoverclk = -hoverclk;
8649 else
8650 {
8651 fall = 0;
8652 fakefall = 0;
8653 int32_t itemid = current_item_id(itype_hoverboots);
8654 if(itemsbuf[itemid].misc1)
8655 hoverclk = itemsbuf[itemid].misc1;
8656 else
8657 {
8658 hoverclk = 1;
8659 hoverflags |= HOV_INF;
8660 }
8661 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8662 }
8663 decorations.add(new dHover(x, y, dHOVER, 0));
8664 }
8665 else
8666 {
8667
3/6
✓ Branch 0 taken 18724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18724 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18724 times.
18724 if (fall <= termv && !(moveflags & move_no_real_z) && z > 0) fall += gravity3;
8668
3/6
✓ Branch 0 taken 18724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18724 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18724 times.
✗ Branch 5 not taken.
18724 if (fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0) fakefall += gravity3;
8669 }
8670 18724 }
8671
1/2
✓ Branch 0 taken 13990362 times.
✗ Branch 1 not taken.
13990362 if (fakez<0) fakez = 0;
8672
1/2
✓ Branch 0 taken 13990362 times.
✗ Branch 1 not taken.
13990362 if (z<0) z = 0;
8673 }
8674
8675
2/2
✓ Branch 0 taken 14308658 times.
✓ Branch 1 taken 748 times.
14309406 if(drunkclk)
8676 {
8677 748 --drunkclk;
8678 748 }
8679
8680
2/2
✓ Branch 0 taken 14308717 times.
✓ Branch 1 taken 689 times.
14309406 if(lstunclock > 0)
8681 {
8682 // also cancel Hero's attack
8683 689 attackclk = 0;
8684
8685
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 261 times.
689 if( FFCore.getHeroAction() != stunned )
8686 {
8687 261 tempaction=action; //update so future checks won't do this
8688 //action=freeze; //setting this makes the player invincible while stunned -V
8689 261 FFCore.setHeroAction(stunned);
8690 261 }
8691 689 --lstunclock;
8692 689 }
8693 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8694 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8695
4/4
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 14308717 times.
✓ Branch 2 taken 655 times.
✓ Branch 3 taken 34 times.
14309406 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8696 {
8697 34 action=tempaction; FFCore.setHeroAction(tempaction);
8698 34 }
8699
8700
1/2
✓ Branch 0 taken 14309406 times.
✗ Branch 1 not taken.
14309406 if( lbunnyclock > 0 )
8701 {
8702 --lbunnyclock;
8703 }
8704
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 14307481 times.
14309406 if(DMaps[cur_dmap].flags&dmfBUNNYIFNOPEARL)
8705 {
8706 1925 int32_t itemid = current_item_id(itype_pearl);
8707
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8708 {
8709
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 122 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8710 1 lbunnyclock = 0;
8711 123 }
8712
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1801 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8713 {
8714 1 lbunnyclock = -1;
8715 1 }
8716 1925 }
8717
1/2
✓ Branch 0 taken 14307481 times.
✗ Branch 1 not taken.
14307481 else if(lbunnyclock == -1) //dmap-caused bunny effect
8718 {
8719 lbunnyclock = 0;
8720 }
8721
8722
7/20
✗ Branch 0 not taken.
✓ Branch 1 taken 14309406 times.
✓ Branch 2 taken 14309406 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14309406 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14309406 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14309406 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14309406 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14309406 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
28618812 bool is_broken_behavior = replay_is_active() && replay_get_meta_str("sav") == "link_to_the_zelda_2_of_3.sav";
8723
5/6
✓ Branch 0 taken 174158 times.
✓ Branch 1 taken 14135248 times.
✓ Branch 2 taken 18776 times.
✓ Branch 3 taken 155382 times.
✓ Branch 4 taken 14154024 times.
✗ Branch 5 not taken.
28463430 bool fall_check = (fall == 0 || z > 0) && (fakefall == 0 || fakez > 0);
8724
2/2
✓ Branch 0 taken 13992613 times.
✓ Branch 1 taken 316793 times.
14309406 if (is_broken_behavior)
8725
5/6
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 315597 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 1040 times.
✗ Branch 5 not taken.
316793 fall_check = (fall == 0 || z > 0) || (fakefall == 0 || fakez > 0);
8726
8727
12/14
✓ Branch 0 taken 14254461 times.
✓ Branch 1 taken 54945 times.
✓ Branch 2 taken 9705827 times.
✓ Branch 3 taken 4548634 times.
✓ Branch 4 taken 9705827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9705827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9705817 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 9704008 times.
✓ Branch 11 taken 1809 times.
✓ Branch 12 taken 78698 times.
✓ Branch 13 taken 9624716 times.
14309406 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && fall_check && charging==0 && spins<=5
8728
2/2
✓ Branch 0 taken 9703414 times.
✓ Branch 1 taken 594 times.
9704008 && action != gothit)
8729 {
8730
2/3
✓ Branch 0 taken 4350754 times.
✓ Branch 1 taken 5273962 times.
✗ Branch 2 not taken.
9624716 switch(dir)
8731 {
8732 case up:
8733 case down:
8734 4350754 x = TRUNCATE_HALF_TILE(x.getInt() + 4);
8735 4350754 break;
8736
8737 case left:
8738 case right:
8739 5273962 y = TRUNCATE_HALF_TILE(y.getInt() + 4);
8740 5273962 break;
8741 }
8742 9624716 }
8743
8744
4/4
✓ Branch 0 taken 137817 times.
✓ Branch 1 taken 14171589 times.
✓ Branch 2 taken 85523 times.
✓ Branch 3 taken 52294 times.
14309406 if((watch==true) && clockclk)
8745 {
8746 52294 --clockclk;
8747
8748
2/2
✓ Branch 0 taken 52151 times.
✓ Branch 1 taken 143 times.
52294 if(!clockclk)
8749 {
8750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(cheat_superman==false)
8751 {
8752 143 setClock(false);
8753 143 }
8754
8755 143 watch=false;
8756
8757
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 143 times.
150 for (auto it : clock_zoras)
8758 {
8759 7 int screen = it.first;
8760 7 int id = it.second;
8761 7 addenemy(screen,0,0,id,0);
8762 }
8763 143 }
8764 52294 }
8765
8766
4/4
✓ Branch 0 taken 14262008 times.
✓ Branch 1 taken 47398 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 14253304 times.
14309406 if(hookshot_frozen || switch_hooked)
8767 {
8768
4/4
✓ Branch 0 taken 11138 times.
✓ Branch 1 taken 44964 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 2434 times.
56102 if(hookshot_used || switch_hooked)
8769 {
8770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53668 times.
53668 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8771 53668 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8772
8773
3/4
✓ Branch 0 taken 36319 times.
✓ Branch 1 taken 17349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36319 times.
53668 if(pull_hero || switch_hooked)
8774 {
8775
3/4
✓ Branch 0 taken 8585 times.
✓ Branch 1 taken 8764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8585 times.
17349 if(hs_switcher || switch_hooked)
8776 {
8777 8764 hs_fix = false;
8778
1/2
✓ Branch 0 taken 8764 times.
✗ Branch 1 not taken.
8764 if(switchhookclk)
8779 {
8780 8764 --switchhookclk;
8781
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 8627 times.
8764 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8782 {
8783
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8784 reset_hookshot();
8785 else
8786 {
8787 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8788 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8789
8790
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 132 times.
137 if(hooked_comborpos != rpos_t::None) //Switching combos
8791 {
8792 132 rpos_t targrpos = hooked_comborpos, plrpos = COMBOPOS_REGION_B(x+8,y+8);
8793
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
132 if (hooked_layerbits && is_valid_rpos(targrpos) && is_valid_rpos(plrpos))
8794 {
8795
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8796
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(int q = max_layer; q > -1; --q)
8797 {
8798
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 792 times.
924 if(!(hooked_layerbits & (1<<q)))
8799 792 continue; //non-switching layer
8800
8801 132 auto target_rpos_handle = get_rpos_handle(targrpos, q);
8802 132 auto player_rpos_handle = get_rpos_handle(plrpos, q);
8803
8804 132 mapscr* target_scr = target_rpos_handle.scr;
8805
8806 132 auto& cmb = target_rpos_handle.combo();
8807 132 int32_t srcfl = target_rpos_handle.sflag();
8808 132 auto& cmb2 = player_rpos_handle.combo();
8809 132 int32_t c = player_rpos_handle.data(),
8810 132 cs = player_rpos_handle.cset(),
8811 132 fl = player_rpos_handle.sflag();
8812 //{Check push status
8813 132 bool isFakePush = false;
8814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.type == cSWITCHHOOK)
8815 {
8816
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8817 isFakePush = true;
8818 132 }
8819 132 bool isPush = isFakePush;
8820
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(srcfl)
8821 {
8822 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8823 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8824 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8825 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8826 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8827 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8828 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8829 isPush = true;
8830 132 }
8831
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
8832 {
8833 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8834 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8835 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8836 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8837 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8838 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8839 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8840 isPush = true;
8841 132 }
8842
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(srcfl==mfPUSHED) isPush = false;
8843 //}
8844
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK) //custom flags and such
8845 {
8846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3) //Breaks on swap
8847 {
8848 int32_t it = -1;
8849 int32_t thedropset = -1;
8850 if(cmb.usrflags&cflag4) //drop item
8851 {
8852 if(cmb.usrflags&cflag5)
8853 it = cmb.attribytes[2];
8854 else
8855 {
8856 it = select_dropitem(cmb.attribytes[2]);
8857 thedropset = cmb.attribytes[2];
8858 }
8859 }
8860
8861 breakable* br = new breakable(x, y, 0_zf,
8862 cmb, target_rpos_handle.cset(), it, thedropset, cmb.attribytes[2],
8863 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8864 br->switch_hooked = true;
8865 decorations.add(br);
8866 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8867 hooked_undercombos[q] = -1;
8868
8869 if(cmb.usrflags&cflag6)
8870 {
8871 target_rpos_handle.increment_data();
8872 }
8873 else
8874 {
8875 target_rpos_handle.set_data(target_scr->undercombo);
8876 target_rpos_handle.set_cset(target_scr->undercset);
8877 if(cmb.usrflags&cflag2)
8878 target_rpos_handle.set_sflag(0);
8879 }
8880 }
8881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 else if(isPush)
8882 {
8883 //Simulate a block clicking into place
8884 movingblock mtemp;
8885 mtemp.clear();
8886
8887 auto [mx, my] = COMBOXY_REGION(plrpos);
8888
8889 mtemp.set(mx,my,target_rpos_handle.data(),target_rpos_handle.cset(),q,target_rpos_handle.sflag());
8890 mtemp.dir = getPushDir(target_rpos_handle.sflag());
8891 if(mtemp.dir < 0)
8892 mtemp.dir = getPushDir(cmb.flag);
8893 mtemp.clk = 1;
8894 mtemp.force_many = isFakePush;
8895 mtemp.no_icy = true;
8896 mtemp.animate(0);
8897 if((mtemp.bhole || mtemp.trigger)
8898 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8899 || cmb2.flag == mfBLOCKTRIGGER
8900 || cmb2.flag == mfBLOCKHOLE))
8901 {
8902 target_rpos_handle.set_data(target_scr->undercombo);
8903 target_rpos_handle.set_cset(target_scr->undercset);
8904 target_rpos_handle.set_sflag(0);
8905 }
8906 else
8907 {
8908 target_rpos_handle.set_data(c);
8909 target_rpos_handle.set_cset(cs);
8910 if(cmb.usrflags&cflag2)
8911 target_rpos_handle.set_sflag(fl);
8912 else
8913 target_rpos_handle.set_sflag(0);
8914 }
8915 }
8916 else
8917 {
8918 132 player_rpos_handle.set_data(target_rpos_handle.data());
8919 132 player_rpos_handle.set_cset(target_rpos_handle.cset());
8920
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
8921 player_rpos_handle.set_sflag(target_rpos_handle.sflag());
8922
8923 132 target_rpos_handle.set_data(c);
8924 132 target_rpos_handle.set_cset(cs);
8925
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
8926 target_rpos_handle.set_sflag(fl);
8927 }
8928 132 }
8929 else if(isCuttableType(cmb.type)) //Break and drop effects
8930 {
8931 int32_t breakcs = target_rpos_handle.cset();
8932 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8933 {
8934 target_rpos_handle.increment_data();
8935 }
8936 else
8937 {
8938 target_rpos_handle.set_data(target_scr->undercombo);
8939 target_rpos_handle.set_cset(target_scr->undercset);
8940 target_rpos_handle.set_sflag(0);
8941 }
8942
8943 int32_t it = -1;
8944 int32_t thedropset = -1;
8945 if(isCuttableItemType(cmb.type)) //Drop an item
8946 {
8947 if ( (cmb.usrflags&cflag2) )
8948 {
8949 if(cmb.usrflags&cflag11)
8950 it = cmb.attribytes[1];
8951 else
8952 {
8953 it = select_dropitem(cmb.attribytes[1]);
8954 thedropset = cmb.attribytes[1];
8955 }
8956 }
8957 else
8958 {
8959 it = select_dropitem(12);
8960 thedropset = 12;
8961 }
8962 }
8963
8964 byte breaksfx = 0;
8965 if(get_qr(qr_MORESOUNDS)) //SFX
8966 {
8967 if (cmb.usrflags&cflag3)
8968 {
8969 breaksfx = cmb.attribytes[2];
8970 }
8971 else if(isBushType(cmb.type)
8972 || isFlowersType(cmb.type)
8973 || isGrassType(cmb.type))
8974 {
8975 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8976 }
8977 }
8978
8979 //Clipping sprite
8980 int16_t decotype = (cmb.usrflags & cflag1) ?
8981 ((cmb.usrflags & cflag10)
8982 ? (cmb.attribytes[0])
8983 : (-1))
8984 : (0);
8985 if(decotype > 3) decotype = 0;
8986 if(!decotype)
8987 decotype = (isBushType(cmb.type) ? 1
8988 : (isFlowersType(cmb.type) ? 2
8989 : (isGrassType(cmb.type) ? 3
8990 : ((cmb.usrflags & cflag1) ? -1
8991 : -2))));
8992
8993 breakable* br = new breakable(x, y, 0_zf,
8994 cmb, breakcs, it, thedropset, breaksfx,
8995 decotype, cmb.attribytes[0], switchhookclk);
8996 br->switch_hooked = true;
8997 decorations.add(br);
8998 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8999 hooked_undercombos[q] = -1;
9000 }
9001 else //Unknown type, just swap combos.
9002 {
9003 if(isPush)
9004 {
9005 //Simulate a block clicking into place
9006 movingblock mtemp;
9007 mtemp.clear();
9008
9009 auto [mx, my] = COMBOXY_REGION(plrpos);
9010
9011 mtemp.set(mx,my,target_rpos_handle.data(),target_rpos_handle.cset(),q,target_rpos_handle.sflag());
9012 mtemp.dir = getPushDir(target_rpos_handle.sflag());
9013 if(mtemp.dir < 0)
9014 mtemp.dir = getPushDir(cmb.flag);
9015 mtemp.clk = 1;
9016 mtemp.animate(0);
9017 if(mtemp.bhole || mtemp.trigger)
9018 {
9019 target_rpos_handle.set_data(target_scr->undercombo);
9020 target_rpos_handle.set_cset(target_scr->undercset);
9021 target_rpos_handle.set_sflag(0);
9022 }
9023 else
9024 {
9025 target_rpos_handle.set_data(c);
9026 target_rpos_handle.set_cset(cs);
9027 target_rpos_handle.set_sflag(0);
9028 }
9029 }
9030 else
9031 {
9032 player_rpos_handle.set_data(target_rpos_handle.data());
9033 player_rpos_handle.set_cset(target_rpos_handle.cset());
9034 target_rpos_handle.set_data(c);
9035 target_rpos_handle.set_cset(cs);
9036 }
9037 }
9038 132 }
9039
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(switchhook_cost_item > -1)
9040 paymagiccost(switchhook_cost_item);
9041 132 zfix tx = x, ty = y;
9042
9043 //Position the player at the combo
9044 132 std::tie(x, y) = COMBOXY_REGION(targrpos);
9045
9046 132 dir = oppositeDir[dir];
9047
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if(w && hw)
9048 {
9049 //Calculate chain shift
9050 zfix dx = (x-tx);
9051 zfix dy = (y-ty);
9052 if(w->dir < 4)
9053 {
9054 if(w->dir & 2)
9055 dx = 0;
9056 else dy = 0;
9057 }
9058 //Position the hook head at the handle
9059 w->x = hw->x + dx;
9060 w->y = hw->y + dy;
9061 w->dir = oppositeDir[w->dir];
9062 w->doAutoRotate(true);
9063 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9064 w->flip ^= hflip;
9065 //Position the handle appropriately
9066 hw->x = x-(hw->x-tx);
9067 hw->y = y-(hw->y-ty);
9068 hw->dir = oppositeDir[hw->dir];
9069 hw->doAutoRotate(true);
9070 hw->flip ^= hflip;
9071 //Move chains
9072 for(int32_t j=0; j<chainlinks.Count(); j++)
9073 {
9074 chainlinks.spr(j)->x += dx;
9075 chainlinks.spr(j)->y += dy;
9076 }
9077 }
9078 132 hooked_comborpos = plrpos; //flip positions
9079 132 }
9080 else reset_hookshot();
9081 132 }
9082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(switching_object) //Switching an object
9083 {
9084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(switchhook_cost_item > -1)
9085 paymagiccost(switchhook_cost_item);
9086 5 zfix tx = x, ty = y;
9087 //Position the player at the object
9088 5 x = switching_object->x;
9089 5 y = switching_object->y;
9090 5 dir = oppositeDir[dir];
9091 //Position the object at the player
9092 5 switching_object->x = tx;
9093 5 switching_object->y = ty;
9094
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
5 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
9095 2 switching_object->dir = oppositeDir[switching_object->dir];
9096 5 solid_update(false);
9097 5 switching_object->solid_update(false);
9098
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(item* it = dynamic_cast<item*>(switching_object))
9099 {
9100 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
9101 {
9102 movefairynew2(it->x, it->y, *it);
9103 }
9104 }
9105
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 if(w && hw) //!TODO No fucking clue if diagonals work
9106 {
9107 //Calculate chain shift
9108 1 zfix dx = (x-tx);
9109 1 zfix dy = (y-ty);
9110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
9111 {
9112
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
9113 1 dx = 0;
9114 else dy = 0;
9115 1 }
9116 //Position the hook head at the handle
9117 1 w->x = hw->x + dx;
9118 1 w->y = hw->y + dy;
9119 1 w->dir = oppositeDir[w->dir];
9120 1 w->doAutoRotate(true);
9121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9122 1 w->flip ^= hflip;
9123 1 w->solid_update(false);
9124 //Position the handle appropriately
9125 1 hw->x = x-(hw->x-tx);
9126 1 hw->y = y-(hw->y-ty);
9127 1 hw->dir = oppositeDir[hw->dir];
9128 1 hw->doAutoRotate(true);
9129 1 hw->flip ^= hflip;
9130 1 hw->solid_update(false);
9131 //Move chains
9132
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
9133 {
9134 5 chainlinks.spr(j)->x += dx;
9135 5 chainlinks.spr(j)->y += dy;
9136 5 }
9137 1 }
9138 5 }
9139 }
9140 137 }
9141
2/2
✓ Branch 0 taken 8490 times.
✓ Branch 1 taken 137 times.
8627 else if(!switchhookclk)
9142 {
9143 137 reset_hookshot();
9144 137 }
9145 8764 }
9146 else reset_hookshot();
9147 8764 }
9148 else
9149 {
9150 sprite *t;
9151 int32_t i;
9152
9153
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 8585 times.
8761 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
9154 {
9155 /* do nothing */
9156 176 }
9157
9158 8585 t = Lwpns.spr(i);
9159
9160
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 8585 times.
25984 for(i=0; i<Lwpns.Count(); i++)
9161 {
9162 17399 sprite *s = Lwpns.spr(i);
9163
9164
2/2
✓ Branch 0 taken 8814 times.
✓ Branch 1 taken 8585 times.
17399 if(s->id==wHookshot)
9165 {
9166
2/2
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 6487 times.
8585 if (abs((s->y) - y) >= 1)
9167 {
9168
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1219 times.
2098 if((s->y)>y)
9169 {
9170 879 y+=4;
9171
9172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 if(Lwpns.idFirst(wHSHandle)!=-1)
9173 {
9174 879 t->y+=4;
9175 879 }
9176
9177 879 hs_starty+=4;
9178 879 }
9179
9180
2/2
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 879 times.
2098 if((s->y)<y)
9181 {
9182 1219 y-=4;
9183
9184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1219 times.
1219 if(Lwpns.idFirst(wHSHandle)!=-1)
9185 {
9186 1219 t->y-=4;
9187 1219 }
9188
9189 1219 hs_starty-=4;
9190 1219 }
9191 2098 }
9192 else
9193 {
9194 6487 y = (s->y);
9195 }
9196
2/2
✓ Branch 0 taken 6487 times.
✓ Branch 1 taken 2098 times.
8585 if (abs((s->x) - x) >= 1)
9197 {
9198
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 3152 times.
6487 if((s->x)>x)
9199 {
9200 3335 x+=4;
9201
9202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3335 times.
3335 if(Lwpns.idFirst(wHSHandle)!=-1)
9203 {
9204 3335 t->x+=4;
9205 3335 }
9206
9207 3335 hs_startx+=4;
9208 3335 }
9209
9210
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 3335 times.
6487 if((s->x)<x)
9211 {
9212 3152 x-=4;
9213
9214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
3152 if(Lwpns.idFirst(wHSHandle)!=-1)
9215 {
9216 3152 t->x-=4;
9217 3152 }
9218
9219 3152 hs_startx-=4;
9220 3152 }
9221 6487 }
9222 else
9223 {
9224 2098 x = (s->x);
9225 }
9226 8585 }
9227 17399 }
9228 }
9229 17349 }
9230 53668 }
9231 else
9232 {
9233 2434 Lwpns.del(Lwpns.idFirst(wHSHandle));
9234 2434 reset_hookshot();
9235 }
9236
9237
1/2
✓ Branch 0 taken 56102 times.
✗ Branch 1 not taken.
56102 if(hs_fix)
9238 {
9239 if(dir==up || dir==down)
9240 {
9241 y = TRUNCATE_TILE(int32_t(y+7));
9242 }
9243
9244 if(dir==left || dir==right)
9245 {
9246 x = TRUNCATE_TILE(int32_t(x+7));
9247 }
9248
9249 hs_fix=false;
9250 }
9251
9252 56102 }
9253
9254
2/2
✓ Branch 0 taken 1338192 times.
✓ Branch 1 taken 12971214 times.
14309406 if(!get_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP))
9255 {
9256
2/2
✓ Branch 0 taken 5312 times.
✓ Branch 1 taken 12965902 times.
12971214 if(DrunkrLbtn())
9257 5312 selectNextBWpn(SEL_LEFT);
9258
2/2
✓ Branch 0 taken 12958427 times.
✓ Branch 1 taken 7475 times.
12965902 else if(DrunkrRbtn())
9259 7475 selectNextBWpn(SEL_RIGHT);
9260 12971214 }
9261
4/4
✓ Branch 0 taken 1026145 times.
✓ Branch 1 taken 13283261 times.
✓ Branch 2 taken 1015490 times.
✓ Branch 3 taken 10655 times.
14309406 if (get_qr(qr_SELECTAWPN) && get_qr(qr_USE_EX1_EX2_INVENTORYSWAP))
9262 {
9263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
9264 selectNextAWpn(SEL_LEFT);
9265
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
9266 1 selectNextAWpn(SEL_RIGHT);
9267 10655 }
9268
9269
2/2
✓ Branch 0 taken 14308328 times.
✓ Branch 1 taken 1078 times.
14309406 if(rPbtn())
9270 {
9271
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1075 times.
1078 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
9272 1075 onViewMap();
9273 1078 }
9274
2/2
✓ Branch 0 taken 5057706 times.
✓ Branch 1 taken 14309406 times.
19367112 for(int32_t i=0; i<Lwpns.Count(); i++)
9275 {
9276 5057706 weapon *w = ((weapon*)Lwpns.spr(i));
9277
9278
6/6
✓ Branch 0 taken 5005462 times.
✓ Branch 1 taken 52244 times.
✓ Branch 2 taken 4542324 times.
✓ Branch 3 taken 463138 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 4542251 times.
5057706 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
9279 515455 addsparkle(i);
9280 5057706 }
9281
9282
2/2
✓ Branch 0 taken 14308171 times.
✓ Branch 1 taken 1235 times.
14309406 if(Lwpns.idCount(wPhantom))
9283 {
9284 1235 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
9285 1235 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
9286 1235 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
9287 1235 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
9288 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
9289 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
9290 1235 }
9291
9292 // Pay magic cost for Byrna beams
9293
9294 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
9295
2/2
✓ Branch 0 taken 14309333 times.
✓ Branch 1 taken 73 times.
14309406 if(Lwpns.idCount(wCByrna))
9296 {
9297 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
9298 73 int32_t itemid = ew->parentitem;
9299
9300
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
9301 {
9302 for(int32_t i=0; i<Lwpns.Count(); i++)
9303 {
9304 weapon *w = ((weapon*)Lwpns.spr(i));
9305
9306 if(w->id==wCByrna)
9307 {
9308 w->dead=1;
9309 }
9310
9311 }
9312 //kill the sound effect for the orbits -Z 14FEB2019
9313 stop_sfx(itemsbuf[itemid].usesound);
9314 }
9315 73 else paymagiccost(itemid);
9316 73 }
9317
9318
3/4
✓ Branch 0 taken 14290300 times.
✓ Branch 1 taken 19106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14290300 times.
14309406 if(z==0&&fakez==0)
9319 {
9320 14290300 standing_on_z = 0;
9321
1/2
✓ Branch 0 taken 14290300 times.
✗ Branch 1 not taken.
14290300 if(standing_z_offset)
9322 {
9323 standing_z_offset=false;
9324 yofs += 8;
9325 }
9326 14290300 }
9327
2/2
✓ Branch 0 taken 319044 times.
✓ Branch 1 taken 13990362 times.
14309406 if(!isSideViewHero())
9328 {
9329 13990362 int32_t tx = x.getInt()+8,
9330 13990362 ty = y.getInt()+8;//(bigHitbox?8:12);
9331
4/4
✓ Branch 0 taken 13989926 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 13989558 times.
13990362 if (unsigned(ty) < world_h && unsigned(tx) < world_w)
9332 {
9333 13989558 rpos_t rpos = COMBOPOS_REGION_B(tx, ty);
9334
2/2
✓ Branch 0 taken 13989058 times.
✓ Branch 1 taken 41968154 times.
55957212 for(int32_t q = 0; q < 3; ++q)
9335 {
9336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41968154 times.
41968154 if (rpos == rpos_t::None) break;
9337
9338 41968154 auto rpos_handle = get_rpos_handle(rpos, q);
9339
2/2
✓ Branch 0 taken 21793847 times.
✓ Branch 1 taken 20174307 times.
41968154 if (!rpos_handle.scr->is_valid()) continue;
9340
9341 21793847 auto& cmb = rpos_handle.combo();
9342
2/2
✓ Branch 0 taken 21788743 times.
✓ Branch 1 taken 5104 times.
21793847 bool standing_switchblock = cmb.type == cCSWITCHBLOCK && (cmb.usrflags & cflag9);
9343
2/2
✓ Branch 0 taken 21793811 times.
✓ Branch 1 taken 36 times.
21793847 bool standing_combo = (cmb.genflags & cflag3) && !standing_switchblock;
9344
4/4
✓ Branch 0 taken 21793375 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 21793339 times.
21793847 if(!(standing_switchblock || standing_combo)) continue;
9345
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 36 times.
508 bool should_z_offs = standing_switchblock ? (cmb.usrflags&cflag10) : (cmb.genflags & cflag4);
9346
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 36 times.
508 zfix cmb_z = standing_switchblock ? zslongToFix(cmb.attributes[2]) : cmb.z_height;
9347 508 int32_t b = 1;
9348
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 146 times.
508 if(tx&8) b <<= 2;
9349
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 138 times.
508 if(ty&8) b <<= 1;
9350 508 b |= (b<<4); //check equivalent effect flag too
9351
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 500 times.
508 if((cmb.walk&b)==b) //solid and effecting
9352 {
9353
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
500 if(z==0&&fakez==0)
9354 {
9355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if(should_z_offs)
9356 {
9357 if(!standing_z_offset)
9358 {
9359 standing_z_offset=true;
9360 yofs -= 8;
9361 }
9362 }
9363 else
9364 {
9365
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(standing_z_offset)
9366 {
9367 standing_z_offset=false;
9368 yofs += 8;
9369 }
9370 }
9371 78 }
9372
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(cmb_z>0 && standing_on_z>=0)
9373 {
9374
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
500 if(z==0&&fakez==0)
9375
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 standing_on_z = zc_max(standing_on_z,cmb_z);
9376
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
✓ Branch 4 taken 398 times.
✓ Branch 5 taken 24 times.
422 else if(STANDING_Z_STATE < cmb_z)
9377 {
9378
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 standing_on_z += cmb_z-STANDING_Z_STATE;
9379 24 }
9380 500 }
9381 else standing_on_z = -1;
9382 500 break;
9383 }
9384 8 }
9385 13989558 }
9386 13990362 }
9387 14309406 ClearhitHeroUIDs(); //clear them before we advance.
9388 14309406 checkhit();
9389
9390 14309406 bool forcedeath = dying_flags&DYING_FORCED;
9391 14309406 bool norev = (dying_flags&DYING_NOREV);
9392
4/6
✓ Branch 0 taken 14309406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 14308830 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 576 times.
14309406 if(forcedeath || (game->get_life()<=0 && !immortal))
9393 {
9394
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(forcedeath)
9395 game->set_life(0);
9396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(!norev)
9397
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 147456 times.
148032 for(size_t slot = 0; slot < 256; ++slot)
9398 {
9399
2/2
✓ Branch 0 taken 147448 times.
✓ Branch 1 taken 8 times.
147456 if(size_t bind = game->get_bottle_slot(slot))
9400 {
9401 8 bottletype const* bt = &QMisc.bottle_types[bind-1];
9402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9403 8 continue;
9404 word toFill[3] = { 0 };
9405 for(size_t q = 0; q < 3; ++q)
9406 {
9407 char c = bt->counter[q];
9408 if(c > -1)
9409 {
9410 if(bt->flags & (1<<q))
9411 {
9412 toFill[q] = (bt->amount[q]==100)
9413 ? game->get_maxcounter(c)
9414 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9415 }
9416 else toFill[q] = bt->amount[q];
9417 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9418 {
9419 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9420 }
9421 }
9422 }
9423 if(bt->flags & BTFLAG_CURESWJINX)
9424 {
9425 swordclk = 0;
9426 verifyAWpn();
9427 }
9428 if(bt->flags & BTFLAG_CUREITJINX)
9429 itemclk = 0;
9430 if(bt->flags & BTFLAG_CURESHJINX)
9431 shieldjinxclk = 0;
9432 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9433 {
9434 int32_t itemid = find_bottle_for_slot(slot,true);
9435 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9436 if(itemid > -1)
9437 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9438 for(size_t q = 0; q < 20; ++q)
9439 do_death_refill_waitframe();
9440 double inc = max/60.0; //1 second
9441 double xtra[3]{ 0 };
9442 for(size_t q = 0; q < 60; ++q)
9443 {
9444 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9445 sfx(QMisc.miscsfx[sfxREFILL]);
9446 for(size_t j = 0; j < 3; ++j)
9447 {
9448 xtra[j] += inc;
9449 word f = floor(xtra[j]);
9450 xtra[j] -= f;
9451 if(toFill[j] > f)
9452 {
9453 toFill[j] -= f;
9454 game->change_counter(f,bt->counter[j]);
9455 }
9456 else if(toFill[j])
9457 {
9458 game->change_counter(toFill[j],bt->counter[j]);
9459 toFill[j] = 0;
9460 }
9461 }
9462 do_death_refill_waitframe();
9463 }
9464 for(size_t j = 0; j < 3; ++j)
9465 {
9466 if(toFill[j])
9467 {
9468 game->change_counter(toFill[j],bt->counter[j]);
9469 toFill[j] = 0;
9470 }
9471 }
9472 for(size_t q = 0; q < 20; ++q)
9473 do_death_refill_waitframe();
9474 }
9475 game->set_bottle_slot(slot,bt->next_type);
9476 if(game->get_life() > 0)
9477 {
9478 dying_flags = 0;
9479 forcedeath = false;
9480 break; //Revived! Stop drinking things...
9481 }
9482 }
9483 148024 }
9484
9485
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 500 times.
576 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9486 {
9487
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
76 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9488 {
9489 // So scripts can have one frame to handle hp zero events
9490
3/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 43 times.
76 if(norev || false == (last_hurrah = !last_hurrah))
9491 {
9492 33 dying_flags = 0;
9493 33 drunkclk=0;
9494 33 lstunclock = 0;
9495 33 is_conveyor_stunned = 0;
9496 33 FFCore.setHeroAction(dying);
9497 33 FFCore.deallocateAllScriptOwned(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9498 33 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
9499 33 ALLOFF(true,true);
9500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(lift_wpn)
9501 {
9502 delete lift_wpn;
9503 lift_wpn = nullptr;
9504 }
9505 33 GameFlags |= GAMEFLAG_NO_F6;
9506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!debug_enabled)
9507 {
9508 33 Paused=false;
9509 33 }
9510
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9511 {
9512 16 FFCore.runOnDeathEngine();
9513 16 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_DEATH);
9514 16 }
9515 33 Playing = false;
9516 33 heroDeathAnimation();
9517
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 17 times.
33 if(get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9518 {
9519 17 Playing = true;
9520 17 FFCore.runOnDeathEngine();
9521 17 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_DEATH);
9522 17 Playing = false;
9523 17 }
9524 33 GameFlags &= ~GAMEFLAG_NO_F6;
9525 33 ALLOFF(true,true);
9526 33 return true;
9527 }
9528 43 }
9529 43 }
9530 else //2.50.x
9531 {
9532 // So scripts can have one frame to handle hp zero events
9533
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 251 times.
500 if(false == (last_hurrah = !last_hurrah))
9534 {
9535 249 drunkclk=0;
9536 249 heroDeathAnimation();
9537
9538 249 return true;
9539 }
9540 }
9541 294 }
9542 14308830 else last_hurrah=false;
9543
9544
2/2
✓ Branch 0 taken 14259643 times.
✓ Branch 1 taken 49481 times.
14309124 if(swordclk>0)
9545 {
9546 49481 --swordclk;
9547
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 49143 times.
49481 if(!swordclk) verifyAWpn();
9548 49481 }
9549
2/2
✓ Branch 0 taken 14299252 times.
✓ Branch 1 taken 9872 times.
14309124 if(itemclk>0)
9550 9872 --itemclk;
9551
1/2
✓ Branch 0 taken 14309124 times.
✗ Branch 1 not taken.
14309124 if(shieldjinxclk>0)
9552 --shieldjinxclk;
9553
9554
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 14307786 times.
14309124 if(inwallm)
9555 {
9556 1338 attackclk=0;
9557 1338 herostep();
9558
9559
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 9 times.
1338 if(CarryHero()==false)
9560 9 restart_level();
9561
9562 1338 solid_update(false);
9563 1338 return false;
9564 }
9565
9566
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14307783 times.
14307786 if(ewind_restart)
9567 {
9568 3 attackclk=0;
9569 3 restart_level();
9570 3 xofs=0;
9571 3 action=none; FFCore.setHeroAction(none);
9572 3 ewind_restart=false;
9573 3 solid_update(false);
9574 3 return false;
9575 }
9576
9577
2/2
✓ Branch 0 taken 14293702 times.
✓ Branch 1 taken 14081 times.
14307783 if(hopclk)
9578 {
9579 14081 action=hopping; FFCore.setHeroAction(hopping);
9580 14081 }
9581
2/2
✓ Branch 0 taken 14304213 times.
✓ Branch 1 taken 3570 times.
14307783 if(fallclk)
9582 {
9583 3570 action=falling; FFCore.setHeroAction(falling);
9584 3570 }
9585
9586
5/6
✓ Branch 0 taken 136379 times.
✓ Branch 1 taken 14171404 times.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 134746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1633 times.
14307783 if(isSwimming() && (liftflags&LIFTFL_DIS_SWIMMING) && !get_qr(qr_BROKEN_LIFTSWIM))
9587 1633 drop_liftwpn();
9588 14307783 handle_passive_buttons();
9589
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 14306847 times.
14307783 if(liftclk)
9590 {
9591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 936 times.
936 if(lift_wpn)
9592 {
9593 936 action=lifting; FFCore.setHeroAction(lifting);
9594 936 }
9595 else
9596 {
9597 liftclk = 0;
9598 tliftclk = 0;
9599 }
9600 936 }
9601
2/2
✓ Branch 0 taken 9454 times.
✓ Branch 1 taken 14297393 times.
14306847 else if(lift_wpn)
9602 {
9603 9454 handle_lift(false);
9604 9454 }
9605
9606
9607 // get user input or do other animation
9608 14307783 freeze_guys=false; // reset this flag, set it again if holding
9609
9610
14/16
✓ Branch 0 taken 14186631 times.
✓ Branch 1 taken 121152 times.
✓ Branch 2 taken 14159669 times.
✓ Branch 3 taken 26962 times.
✓ Branch 4 taken 14158497 times.
✓ Branch 5 taken 1172 times.
✓ Branch 6 taken 14157846 times.
✓ Branch 7 taken 651 times.
✓ Branch 8 taken 14157846 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14157846 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 14134593 times.
✓ Branch 13 taken 23253 times.
✓ Branch 14 taken 14134476 times.
✓ Branch 15 taken 117 times.
14307783 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9611 {
9612 117 holdclk=0;
9613 117 }
9614
9615 14307783 active_shield_id = refreshActiveShield();
9616 14307783 bool sh = active_shield_id > -1;
9617 14307783 itemdata const& shield = itemsbuf[active_shield_id];
9618 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9619 14307783 shield_forcedir = -1;
9620
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14307783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14307783 if(sh && action != rafting && (shield.flags & item_flag11)) //Lock Dir
9621 {
9622 shield_forcedir = dir;
9623 }
9624
1/2
✓ Branch 0 taken 14307783 times.
✗ Branch 1 not taken.
14307783 if(sh != shield_active) //Toggle active shield on/off
9625 {
9626 shield_active = sh;
9627 if(sh) //Toggle active shield on
9628 {
9629 sfx(shield.usesound2); //'Activate' sfx
9630 }
9631 }
9632
9633 14307783 bool isthissolid = false;
9634
12/12
✓ Branch 0 taken 134909 times.
✓ Branch 1 taken 1823 times.
✓ Branch 2 taken 6272 times.
✓ Branch 3 taken 311389 times.
✓ Branch 4 taken 3887 times.
✓ Branch 5 taken 148114 times.
✓ Branch 6 taken 13561625 times.
✓ Branch 7 taken 102697 times.
✓ Branch 8 taken 3570 times.
✓ Branch 9 taken 14081 times.
✓ Branch 10 taken 18480 times.
✓ Branch 11 taken 936 times.
14307783 switch(action)
9635 {
9636 case gothit:
9637
2/2
✓ Branch 0 taken 100399 times.
✓ Branch 1 taken 2298 times.
102697 if(attackclk)
9638
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 308 times.
2606 if(!doattack())
9639 {
9640 308 attackclk=spins=0;
9641 308 tapping=false;
9642 308 }
9643
9644 102697 break;
9645
9646 case drowning:
9647 case lavadrowning:
9648 case sidedrowning:
9649 {
9650 6272 herostep(); // maybe this line should be elsewhere?
9651
9652 //!DROWN
9653 // Helpful comment to find drowning -Dimi
9654
9655 6272 drop_liftwpn();
9656
2/2
✓ Branch 0 taken 6174 times.
✓ Branch 1 taken 98 times.
6272 if(--drownclk==0)
9657 {
9658 98 action=none; FFCore.setHeroAction(none);
9659 98 optional<combined_handle_t> comb_handle;
9660 98 int32_t water = iswaterex_z3(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), -1, x.getInt()+7.5,y.getInt()+12, true, false, true, false, true, &comb_handle);
9661
3/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 34 times.
98 if(drownCombo && water != drownCombo)
9662 {
9663 34 comb_handle = nullopt;
9664 34 water = drownCombo;
9665 34 }
9666
9667 98 std::vector<int32_t> &ev = FFCore.eventData;
9668 98 ev.clear();
9669 98 ev.push_back(water*10000);
9670
9671 98 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9672 98 water = ev[0]/10000;
9673 98 newcombo const& watercmb = combobuf[water];
9674
9675 98 int32_t damage = 4;
9676
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 30 times.
98 if (watercmb.type == cWATER)
9677 68 damage = watercmb.attributes[0]/10000L;
9678 30 else water = 0;
9679
9680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if(cheat_superman && damage > 0)
9681 damage = 0;
9682
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(damage)
9683 98 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9684 98 drownCombo = 0;
9685
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 64 times.
98 if(comb_handle)
9686 64 do_trigger_ctype_causes(*comb_handle);
9687 98 go_respawn_point();
9688 98 hclk=48;
9689 98 check_on_hit();
9690 98 }
9691
9692 6272 break;
9693 }
9694 case falling:
9695 {
9696 3570 herostep();
9697 3570 pitfall();
9698 3570 break;
9699 }
9700 case freeze:
9701 case sideswimfreeze:
9702 case scrolling:
9703 311389 break;
9704
9705 case casting:
9706 case sideswimcasting:
9707 {
9708
2/2
✓ Branch 0 taken 3878 times.
✓ Branch 1 taken 9 times.
3887 if(magicitem==-1)
9709 {
9710 9 action=none; FFCore.setHeroAction(none);
9711 9 }
9712
9713 3887 break;
9714 }
9715 case landhold1:
9716 case landhold2:
9717 {
9718
2/2
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 146872 times.
148114 if(--holdclk <= 0)
9719 {
9720 //restart music
9721
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1157 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 35 times.
1242 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9722 35 playLevelMusic();
9723
9724 1242 action=none; FFCore.setHeroAction(none);
9725 1242 post_item_collect();
9726 1242 }
9727 else
9728 146872 freeze_guys=true;
9729
9730 148114 break;
9731 }
9732 case waterhold1:
9733 case waterhold2:
9734 case sidewaterhold1:
9735 case sidewaterhold2:
9736 {
9737 1823 diveclk=0;
9738
9739
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1807 times.
1823 if(--holdclk <= 0)
9740 {
9741 //restart music
9742
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9743 playLevelMusic();
9744
9745 16 SetSwim();
9746 16 post_item_collect();
9747 16 }
9748 else
9749 1807 freeze_guys=true;
9750
9751 1823 break;
9752 }
9753 case hopping:
9754 {
9755
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 14068 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
14081 if(DRIEDLAKE)
9756 {
9757 action=none; FFCore.setHeroAction(none);
9758 hopclk = 0;
9759 diveclk = 0;
9760 break;
9761 }
9762
9763 14081 do_hopping();
9764 14081 break;
9765 }
9766 case inwind:
9767 {
9768 18480 int32_t i=Lwpns.idFirst(wWind);
9769
9770
2/2
✓ Branch 0 taken 18243 times.
✓ Branch 1 taken 237 times.
18480 if(i<0)
9771 {
9772 237 bool exit=false;
9773
9774
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 112 times.
237 if(whirlwind==255)
9775 {
9776 125 exit=true;
9777 125 }
9778 // When the wind weapon goes away, check if the player has been brought to the edge of the screen
9779 // by the wind. If so, push them one more pixel to trigger the screen scrolling code.
9780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==up && y<=viewport.top()) y=viewport.top()-1;
9781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==down && y>=viewport.bottom()-16) y=viewport.bottom()-16+1;
9782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==left && x<=viewport.left()) x=viewport.left()-1;
9783
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 else if (dir==right && x>=viewport.right()-16) x=viewport.right()-16+1;
9784 else exit=true;
9785
9786
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 125 times.
237 if(exit)
9787 {
9788 125 action=none; FFCore.setHeroAction(none);
9789 125 xofs=0;
9790 125 whirlwind=0;
9791 125 lstep=0;
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if ( dontdraw < 2 ) dontdraw=0;
9793 125 set_respawn_point();
9794 125 }
9795 237 }
9796 else
9797 {
9798 18243 auto wind = Lwpns.spr(i);
9799 18243 x = wind->x;
9800 18243 y = wind->y;
9801 18243 dir = wind->dir;
9802 }
9803 }
9804 18480 break;
9805 case lifting:
9806 936 handle_lift();
9807 936 break;
9808
9809 case sideswimming:
9810 case sideswimattacking:
9811 case sideswimhit:
9812 case swimhit:
9813 case swimming:
9814 {
9815
3/4
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 134743 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
134909 if(DRIEDLAKE)
9816 {
9817 action=none; FFCore.setHeroAction(none);
9818 hopclk=0;
9819 break;
9820 }
9821
9822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
134909 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9823
9824
4/4
✓ Branch 0 taken 67399 times.
✓ Branch 1 taken 67510 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 66773 times.
134909 if((frame&1) && !shouldbreak)
9825 66773 herostep();
9826
9827
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134909 times.
✓ Branch 4 taken 10279 times.
✓ Branch 5 taken 124630 times.
145411 if (_walkflag(x+7,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
9828
4/6
✓ Branch 0 taken 124407 times.
✓ Branch 1 taken 10502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10502 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10502 times.
134909 || _walkflag(x+7,y+(bigHitbox?9:12),1,STANDING_Z_STATE)
9829
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10493 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10493 times.
10502 || _walkflag(x+8,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
9830
4/6
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 10279 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10279 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10279 times.
135123 || _walkflag(x+8,y+(bigHitbox?9:12),1,STANDING_Z_STATE)) isthissolid = true;
9831
4/4
✓ Branch 0 taken 126779 times.
✓ Branch 1 taken 8130 times.
✓ Branch 2 taken 126779 times.
✓ Branch 3 taken 8130 times.
134909 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9832 {
9833
4/4
✓ Branch 0 taken 8082 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 8027 times.
✓ Branch 3 taken 4 times.
16161 if(!iswaterex_z3(MAPCOMBO(x.getInt()+4,y.getInt()+9), -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex_z3(MAPCOMBO(x.getInt()+4,y.getInt()+15), -1, x.getInt()+4,y.getInt()+15, true, false)
9834
4/4
✓ Branch 0 taken 8058 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 27 times.
8082 || !iswaterex_z3(MAPCOMBO(x.getInt()+11,y.getInt()+9), -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex_z3(MAPCOMBO(x.getInt()+11,y.getInt()+15), -1, x.getInt()+11,y.getInt()+15, true, false))
9835 {
9836 103 hopclk=0;
9837 103 diveclk=0;
9838
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9839 else {action=attacking; FFCore.setHeroAction(attacking);}
9840 103 hopdir=-1;
9841 103 }
9842 8130 }
9843
2/2
✓ Branch 0 taken 1259 times.
✓ Branch 1 taken 133650 times.
134909 if (shouldbreak) break;
9844
4/6
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 133547 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 103 times.
133650 if (action == swimming || action == sideswimming || action == sideswimattacking)
9845 {
9846 133547 int32_t watercheck = iswaterex_z3(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), -1, x.getInt()+7.5,y.getInt()+12, true, false);
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133547 times.
133547 if (combobuf[watercheck].usrflags&cflag2)
9848 {
9849 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9850 {
9851 onpassivedmg = true;
9852 if (damageovertimeclk == 0)
9853 {
9854 int32_t curhp = game->get_life();
9855 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9856 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9857 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9858 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9859 {
9860 hclk = 48;
9861 hitdir = -1;
9862 check_on_hit();
9863 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9864 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9865 }
9866 }
9867 if (combobuf[watercheck].attribytes[1] > 0)
9868 {
9869 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9870 else --damageovertimeclk;
9871 }
9872 else damageovertimeclk = 0;
9873 }
9874 else damageovertimeclk = 0;
9875 }
9876 133547 else damageovertimeclk = 0;
9877 //combobuf[watercheck].attributes[0]
9878 133547 }
9879
9880 133650 }
9881 [[fallthrough]];
9882 default:
9883 // call the main movement routine
9884
2/2
✓ Branch 0 taken 402696 times.
✓ Branch 1 taken 13292579 times.
13695275 if(get_qr(qr_NEW_HERO_MOVEMENT2))
9885 {
9886
2/2
✓ Branch 0 taken 38022 times.
✓ Branch 1 taken 364674 times.
402696 if(premove())
9887 364674 movehero();
9888 402696 }
9889 else
9890 {
9891 13292579 sliding = 0;
9892 13292579 moveheroOld();
9893 }
9894 13695275 }
9895
11/14
✓ Branch 0 taken 319029 times.
✓ Branch 1 taken 13988754 times.
✓ Branch 2 taken 854 times.
✓ Branch 3 taken 318175 times.
✓ Branch 4 taken 854 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 834 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 816 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 816 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 816 times.
14307783 if (isSideViewHero() && slopeid && hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
9896 {
9897
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 222 times.
816 if (!on_sideview_solid_oldpos(this, false, 0))
9898 {
9899 222 zfix dy = 0;
9900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 for (zfix q = 0; q <= 4; ++q)
9901 {
9902
2/2
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 222 times.
728 if (on_sideview_solid_oldpos(this, false, 0, 0, q))
9903 {
9904 222 dy = q;
9905 222 break;
9906 }
9907 506 }
9908
3/6
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222 times.
✗ Branch 5 not taken.
3634 dy = binary_search_zfix(0, dy, [&](zfix val, zfix& retval)
9909 {
9910
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 2398 times.
3412 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
9911 {
9912 1014 retval = val;
9913 1014 return BSEARCH_CONTINUE_TOWARD0;
9914 }
9915 2398 else return BSEARCH_CONTINUE_AWAY0;
9916 3412 });
9917
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 110 times.
222 if (dy) push_move(0, dy);
9918 222 }
9919 816 }
9920
9921
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14307783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14307783 if(shield_forcedir > -1 && action != rafting)
9922 dir = shield_forcedir;
9923
9924
9925 // check for ladder removal
9926
4/6
✓ Branch 0 taken 9749955 times.
✓ Branch 1 taken 4557828 times.
✓ Branch 2 taken 9749955 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9749955 times.
14307783 if(diagonalMovement||NO_GRIDLOCK)
9927 {
9928
2/2
✓ Branch 0 taken 4549167 times.
✓ Branch 1 taken 8661 times.
4557828 if(ladderx+laddery)
9929 {
9930
2/2
✓ Branch 0 taken 3309 times.
✓ Branch 1 taken 5352 times.
8661 if(ladderdir<=down)
9931 {
9932
10/10
✓ Branch 0 taken 2266 times.
✓ Branch 1 taken 1043 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 3241 times.
✓ Branch 4 taken 2229 times.
✓ Branch 5 taken 1012 times.
✓ Branch 6 taken 3210 times.
✓ Branch 7 taken 31 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 3205 times.
3309 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9933 {
9934 104 reset_ladder();
9935 104 }
9936 3309 }
9937 else
9938 {
9939
10/10
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5347 times.
✓ Branch 2 taken 4277 times.
✓ Branch 3 taken 1070 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 5283 times.
✓ Branch 6 taken 4245 times.
✓ Branch 7 taken 1038 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 5194 times.
5352 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9940 {
9941 158 reset_ladder();
9942 158 }
9943 }
9944 8661 }
9945 4557828 }
9946 else
9947 {
9948
4/4
✓ Branch 0 taken 334176 times.
✓ Branch 1 taken 9415779 times.
✓ Branch 2 taken 194313 times.
✓ Branch 3 taken 139863 times.
9749955 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9949 {
9950 9610092 reset_ladder();
9951 9610092 }
9952 }
9953
9954
2/2
✓ Branch 0 taken 13778682 times.
✓ Branch 1 taken 529101 times.
14307783 if(!get_qr(qr_OLD_RESPAWN_POINTS)) //needs to happen after ladder removal so the respawn point is set when laddering over multiple 1 tile gaps.
9955 529101 set_respawn_point(false); //Keep the 'last safe location' updated!
9956
9957
2/2
✓ Branch 0 taken 3220 times.
✓ Branch 1 taken 14304563 times.
14307783 if(ilswim)
9958 3220 landswim++;
9959 14304563 else landswim=0;
9960
9961
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 14307611 times.
14307783 if(hopclk!=0xFF) ilswim=false;
9962
9963
4/4
✓ Branch 0 taken 37969 times.
✓ Branch 1 taken 14269814 times.
✓ Branch 2 taken 3301 times.
✓ Branch 3 taken 34668 times.
14307783 if((!loaded_guys) && (frame - newscr_clk >= 1))
9964 {
9965
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 34651 times.
34668 if(hero_scr->room==rGANON)
9966 {
9967 17 ganon_intro();
9968 17 }
9969 else
9970 {
9971 34651 loadguys();
9972 }
9973 34668 }
9974
9975
2/2
✓ Branch 0 taken 40062 times.
✓ Branch 1 taken 14267721 times.
14307783 if(frame - newscr_clk >= 2)
9976 {
9977 14267721 loadenemies();
9978 14267721 }
9979
9980 // check lots of other things
9981 14307783 checkscroll();
9982
9983
7/8
✓ Branch 0 taken 14289428 times.
✓ Branch 1 taken 18355 times.
✓ Branch 2 taken 14283506 times.
✓ Branch 3 taken 5922 times.
✓ Branch 4 taken 14283506 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 253 times.
✓ Branch 7 taken 14283253 times.
14307783 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9984 {
9985 14283253 checkspecial();
9986 14283253 checkitems();
9987 14283253 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9988
2/2
✓ Branch 0 taken 567384 times.
✓ Branch 1 taken 13715869 times.
14283253 if(get_qr(qr_OLD_LOCKBLOCK_COLLISION))
9989 {
9990 13715869 oldchecklockblock();
9991 13715869 oldcheckbosslockblock();
9992 13715869 }
9993
2/2
✓ Branch 0 taken 1053315 times.
✓ Branch 1 taken 13229938 times.
14283253 if(get_qr(qr_OLD_CHEST_COLLISION))
9994 {
9995 13229938 oldcheckchest(cCHEST);
9996 13229938 oldcheckchest(cLOCKEDCHEST);
9997 13229938 oldcheckchest(cBOSSCHEST);
9998 13229938 }
9999 14283253 checkpushblock();
10000 14283253 checkswordtap();
10001
10002
2/2
✓ Branch 0 taken 47397 times.
✓ Branch 1 taken 14235856 times.
14283253 if(hookshot_frozen==false)
10003 {
10004 14235856 checkspecial2(&lsave);
10005 14235856 }
10006
10007
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14283243 times.
14283253 if(action==won)
10008 {
10009 10 return true;
10010 }
10011 14283243 }
10012
10013 // Somehow Hero was displaced from the fairy flag...
10014
3/6
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14284519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23254 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14307773 if(fairyclk && action != freeze && action != sideswimfreeze)
10015 {
10016 fairyclk = holdclk = refill_why = 0;
10017 }
10018
10019
4/4
✓ Branch 0 taken 14307771 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 14224861 times.
✓ Branch 3 taken 82910 times.
14307773 if((!activated_timed_warp) && (origin_scr->timedwarptics>0))
10020 {
10021 82910 origin_scr->timedwarptics--;
10022
10023
2/2
✓ Branch 0 taken 82411 times.
✓ Branch 1 taken 499 times.
82910 if(origin_scr->timedwarptics==0)
10024 {
10025 499 activated_timed_warp=true;
10026
10027
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 121 times.
499 if(origin_scr->flags4 & fTIMEDDIRECT)
10028 {
10029 121 setpit();
10030 121 }
10031
10032 499 int32_t index2 = 0;
10033
10034
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(origin_scr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
10035
10036 499 sdir = dir;
10037 499 dowarp(origin_scr, 1, index2);
10038 499 }
10039 82910 }
10040
10041 // Global Combo Effects (AUTO STUFF)
10042 14307773 bool awarp = false;
10043 4044733949 for_some_rpos([&](const rpos_handle_t& rpos_handle) {
10044
2/2
✓ Branch 0 taken 273940833 times.
✓ Branch 1 taken 3756485343 times.
4030426176 if (!get_qr(qr_AUTOCOMBO_ANY_LAYER))
10045 {
10046
2/2
✓ Branch 0 taken 4762155 times.
✓ Branch 1 taken 3751723188 times.
3756485343 if (rpos_handle.layer > 2) return false;
10047
4/4
✓ Branch 0 taken 946477664 times.
✓ Branch 1 taken 2805245524 times.
✓ Branch 2 taken 48259552 times.
✓ Branch 3 taken 898218112 times.
3751723188 if (rpos_handle.layer == 1 && !get_qr(qr_AUTOCOMBO_LAYER_1)) return true;
10048
4/4
✓ Branch 0 taken 341433312 times.
✓ Branch 1 taken 2512071764 times.
✓ Branch 2 taken 19404000 times.
✓ Branch 3 taken 322029312 times.
2853505076 if (rpos_handle.layer == 2 && !get_qr(qr_AUTOCOMBO_LAYER_2)) return true;
10049 2531475764 }
10050 2805416597 int32_t ind=0;
10051
10052 //AUTOMATIC TRIGGER CODE
10053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805416597 times.
2986772527 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10054 181355930 return trig.trigger_flags.get(TRIGFLAG_AUTOMATIC);
10055 });
10056 2805416597 newcombo const& cmb = rpos_handle.combo();
10057
10058 //AUTO WARP CODE
10059
2/2
✓ Branch 0 taken 22695 times.
✓ Branch 1 taken 2805393902 times.
2805416597 if (!(cmb.only_gentrig))
10060 {
10061
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 2805393813 times.
2805393902 if(cmb.type==cAWARPA)
10062 {
10063 89 awarp=true;
10064 89 ind=0;
10065 89 }
10066
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2805393750 times.
2805393813 else if(cmb.type==cAWARPB)
10067 {
10068 63 awarp=true;
10069 63 ind=1;
10070 63 }
10071
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2805393747 times.
2805393750 else if(cmb.type==cAWARPC)
10072 {
10073 3 awarp=true;
10074 3 ind=2;
10075 3 }
10076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805393747 times.
2805393747 else if(cmb.type==cAWARPD)
10077 {
10078 awarp=true;
10079 ind=3;
10080 }
10081
1/2
✓ Branch 0 taken 2805393747 times.
✗ Branch 1 not taken.
2805393747 else if(cmb.type==cAWARPR)
10082 {
10083 awarp=true;
10084 ind=zc_oldrand()%4;
10085 }
10086 2805393902 }
10087
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 2805416442 times.
2805416597 if (awarp)
10088 {
10089
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 67 times.
155 if (rpos_handle.scr->flags5 & fDIRECTAWARP)
10090 {
10091 67 setpit();
10092 67 }
10093
10094 155 sdir = dir;
10095 155 dowarp(rpos_handle.scr, 1, ind);
10096 155 return false;
10097 }
10098
10099 2805416442 return true;
10100 4030426176 });
10101
10102 14307773 awarp=false;
10103
10104 453811717 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
10105 439503944 int32_t ind=0;
10106
10107
1/2
✓ Branch 0 taken 439503944 times.
✗ Branch 1 not taken.
439628945 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
10108 125001 return trig.trigger_flags.get(TRIGFLAG_AUTOMATIC);
10109 });
10110 439503944 auto& cmb = ffc_handle.combo();
10111
10112
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 439500036 times.
439503944 if(!(cmb.only_gentrig))
10113 {
10114
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 439500017 times.
439500036 if(cmb.type==cAWARPA)
10115 {
10116 19 awarp=true;
10117 19 ind=0;
10118 19 }
10119
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 439499984 times.
439500017 else if(cmb.type==cAWARPB)
10120 {
10121 33 awarp=true;
10122 33 ind=1;
10123 33 }
10124
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 439499982 times.
439499984 else if(cmb.type==cAWARPC)
10125 {
10126 2 awarp=true;
10127 2 ind=2;
10128 2 }
10129
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 439499978 times.
439499982 else if(cmb.type==cAWARPD)
10130 {
10131 4 awarp=true;
10132 4 ind=3;
10133 4 }
10134
1/2
✓ Branch 0 taken 439499978 times.
✗ Branch 1 not taken.
439499978 else if(cmb.type==cAWARPR)
10135 {
10136 awarp=true;
10137 ind=zc_oldrand()%4;
10138 }
10139 439500036 }
10140
10141
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 439503886 times.
439503944 if(awarp)
10142 {
10143
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(ffc_handle.scr->flags5&fDIRECTAWARP)
10144 {
10145 setpit();
10146 }
10147
10148 58 sdir = dir;
10149 58 dowarp(ffc_handle.scr, 1, ind, 0);
10150 58 return false;
10151 }
10152
10153 439503886 return true;
10154 439503944 });
10155
10156 14307773 zfix dx, dy;
10157
7/8
✓ Branch 0 taken 319028 times.
✓ Branch 1 taken 13988745 times.
✓ Branch 2 taken 158801 times.
✓ Branch 3 taken 160227 times.
✓ Branch 4 taken 746 times.
✓ Branch 5 taken 158055 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 746 times.
14307773 if (sideview_mode() && !on_sideview_solid_oldpos(this, false, 1) && on_sideview_solid_oldpos(this, false, 2) && !toogam)
10158 {
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
746 if (slide_slope(this, dx, dy, slopeid))
10160 {
10161 746 onplatid = 1;
10162
2/4
✓ Branch 0 taken 746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
746 if (dx || dy) push_move(dx, dy);
10163 746 }
10164 746 }
10165
2/2
✓ Branch 0 taken 14306935 times.
✓ Branch 1 taken 838 times.
14307773 if (onplatid <= 0) slopeid = 0;
10166 838 else --onplatid;
10167
2/2
✓ Branch 0 taken 11356227 times.
✓ Branch 1 taken 2951546 times.
14307773 bool onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10168
5/6
✓ Branch 0 taken 1964 times.
✓ Branch 1 taken 14307770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1964 times.
✓ Branch 4 taken 1961 times.
✓ Branch 5 taken 14307773 times.
14309734 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
10169 {
10170 1961 dx = 0;
10171 1961 dy = 0;
10172
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1961 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1961 times.
1961 if (check_slope(this, true) && !toogam)
10173 {
10174 1961 slope_info const& s = get_slope(this, true).get_info();
10175 1961 bool staircheck = false;
10176
3/4
✓ Branch 0 taken 1815 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 1815 times.
✗ Branch 3 not taken.
1961 if (s.slope() != slopeid && slopeid) staircheck = true;
10177
2/2
✓ Branch 0 taken 1914 times.
✓ Branch 1 taken 47 times.
1961 if (onplatform) staircheck = true;
10178 1961 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
10179
10180
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 1780 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 1 times.
1961 if (dx || dy)
10181 {
10182 1960 reset_hookshot();
10183 1960 int32_t pushret = push_move(dx,dy);
10184
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 15 times.
1960 onplatform = (on_sideview_solid_oldpos(this, false, 1) && !Up());
10185
3/4
✓ Branch 0 taken 1814 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 1814 times.
✗ Branch 3 not taken.
1960 if (s.slope() != slopeid && slopeid) staircheck = true;
10186
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 15 times.
1960 if (onplatform) staircheck = true;
10187
4/4
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 1776 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 146 times.
1960 if(sideview_mode() && slopeid)
10188 146 onplatid = 0;
10189
1/2
✓ Branch 0 taken 1960 times.
✗ Branch 1 not taken.
1960 if (pushret == 1)
10190 {
10191 dx = -1;
10192 dy = 0;
10193 slope_push_int(s, this, dx, dy, staircheck);
10194 push_move(0,dy);
10195 }
10196
2/2
✓ Branch 0 taken 1959 times.
✓ Branch 1 taken 1 times.
1960 if (pushret == 2)
10197 {
10198 1 dx = 0;
10199 1 dy = -1;
10200 1 slope_push_int(s, this, dx, dy, staircheck);
10201 1 push_move(dx,0);
10202 1 }
10203 1960 }
10204 1961 }
10205 1961 }
10206
10207
2/2
✓ Branch 0 taken 14307539 times.
✓ Branch 1 taken 234 times.
14307773 if(ffwarp)
10208 {
10209
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 127 times.
234 if(ffpit)
10210 {
10211 127 ffpit=false;
10212 127 setpit();
10213 127 }
10214
10215 234 ffwarp=false;
10216 234 dowarp(hero_scr,1,0);
10217 234 }
10218
10219 //Hero->WarpEx
10220
2/2
✓ Branch 0 taken 14307667 times.
✓ Branch 1 taken 106 times.
14307773 if ( FFCore.warpex[wexActive] )
10221 {
10222 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
10223 106 FFCore.warpex[wexActive] = 0;
10224 106 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
10225
2/2
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 106 times.
1060 for ( int32_t q = 0; q < wexActive; q++ )
10226 {
10227 954 temp_warpex[q] = FFCore.warpex[q];
10228 954 FFCore.warpex[q] = 0;
10229 954 }
10230 212 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
10231 106 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
10232 106 }
10233
10234
4/4
✓ Branch 0 taken 19107 times.
✓ Branch 1 taken 14288666 times.
✓ Branch 2 taken 29187 times.
✓ Branch 3 taken 33526 times.
14307773 if(z == 0 || !get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
10235 {
10236 // walk through bombed doors and fake walls
10237 14322192 bool walk=false;
10238 14322192 int32_t dtype=dBOMBED;
10239
10240
2/2
✓ Branch 0 taken 13958195 times.
✓ Branch 1 taken 296945 times.
14322192 if(pushing>=24) dtype=dWALK;
10241
10242
16/18
✓ Branch 0 taken 6270359 times.
✓ Branch 1 taken 7984781 times.
✓ Branch 2 taken 6133753 times.
✓ Branch 3 taken 136606 times.
✓ Branch 4 taken 6133753 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6122412 times.
✓ Branch 7 taken 11341 times.
✓ Branch 8 taken 6118991 times.
✓ Branch 9 taken 3421 times.
✓ Branch 10 taken 6111784 times.
✓ Branch 11 taken 7207 times.
✓ Branch 12 taken 6098072 times.
✓ Branch 13 taken 13712 times.
✓ Branch 14 taken 6098072 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 92698 times.
✓ Branch 17 taken 6190770 times.
14255140 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
10243 {
10244 6190770 int x0 = x.getInt() % 256;
10245 6190770 int y0 = y.getInt() % 176;
10246
10247
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6061770 times.
✓ Branch 2 taken 1018756 times.
✓ Branch 3 taken 5043014 times.
✓ Branch 4 taken 1013652 times.
✓ Branch 5 taken 5104 times.
✓ Branch 6 taken 1013652 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1013652 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 946981 times.
✓ Branch 11 taken 941877 times.
✓ Branch 12 taken 66446 times.
✓ Branch 13 taken 225 times.
6190770 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x0>112&&x0<128:x0==120) && y0<=32 && hero_scr->door[0]==dtype)
10248 {
10249 225 walk=true;
10250 225 dir=up;
10251 225 }
10252
10253
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6051562 times.
✓ Branch 2 taken 733936 times.
✓ Branch 3 taken 5317626 times.
✓ Branch 4 taken 858767 times.
✓ Branch 5 taken 4169 times.
✓ Branch 6 taken 858767 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 858767 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 815443 times.
✓ Branch 11 taken 811274 times.
✓ Branch 12 taken 43108 times.
✓ Branch 13 taken 216 times.
6180562 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x0>112&&x0<128:x0==120) && y0>=128 && hero_scr->door[1]==dtype)
10254 {
10255 216 walk=true;
10256 216 dir=down;
10257 216 }
10258
10259
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6043224 times.
✓ Branch 2 taken 46925 times.
✓ Branch 3 taken 5996299 times.
✓ Branch 4 taken 101764 times.
✓ Branch 5 taken 219 times.
✓ Branch 6 taken 101764 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 101764 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 105 times.
✓ Branch 11 taken 114 times.
✓ Branch 12 taken 101589 times.
✓ Branch 13 taken 101484 times.
6172224 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x0<=32 && ((diagonalMovement||NO_GRIDLOCK)?y0>72&&y0<88:y0==80) && hero_scr->door[2]==dtype)
10260 {
10261 175 walk=true;
10262 175 dir=left;
10263 175 }
10264
10265
12/14
✓ Branch 0 taken 5969072 times.
✓ Branch 1 taken 129000 times.
✓ Branch 2 taken 41187 times.
✓ Branch 3 taken 5927885 times.
✓ Branch 4 taken 122261 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 122261 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 122261 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 58 times.
✓ Branch 11 taken 34 times.
✓ Branch 12 taken 122066 times.
✓ Branch 13 taken 122008 times.
6098072 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x0>=208 && ((diagonalMovement||NO_GRIDLOCK)?y0>72&&y0<88:y0==80) && hero_scr->door[3]==dtype)
10266 {
10267 195 walk=true;
10268 195 dir=right;
10269 195 }
10270 6050122 }
10271
10272
2/2
✓ Branch 0 taken 14299077 times.
✓ Branch 1 taken 811 times.
14299888 if(walk)
10273 {
10274 811 hclk=0;
10275 811 drawguys=false;
10276
10277
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 195 times.
811 if(dtype==dWALK)
10278 {
10279 195 sfx(hero_scr->secretsfx);
10280
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 if(!get_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE))
10281 set_doorstate(hero_screen, dir);
10282 195 }
10283
10284 811 action=none; FFCore.setHeroAction(none);
10285 811 attackclk = 0;
10286 811 stepforward(29, true);
10287 811 action=scrolling; FFCore.setHeroAction(scrolling);
10288 811 pushing=false;
10289 811 }
10290 14299888 }
10291
10292
5/6
✓ Branch 0 taken 338291 times.
✓ Branch 1 taken 13990784 times.
✓ Branch 2 taken 335798 times.
✓ Branch 3 taken 2493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 335798 times.
14329075 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
10293 {
10294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335798 times.
335798 if(heart_beep)
10295 {
10296 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10297 }
10298 else
10299 {
10300
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 335263 times.
335798 if ( heart_beep_timer == -1 )
10301 {
10302 535 heart_beep_timer = 70;
10303 535 }
10304
10305
2/2
✓ Branch 0 taken 305886 times.
✓ Branch 1 taken 29912 times.
335798 if ( heart_beep_timer > 0 )
10306 {
10307 29912 --heart_beep_timer;
10308 29912 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10309 29912 }
10310 else
10311 {
10312 305886 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10313 }
10314 }
10315 335798 }
10316 else
10317 {
10318
2/2
✓ Branch 0 taken 27076 times.
✓ Branch 1 taken 13971973 times.
13993277 if ( heart_beep_timer > -2 )
10319 {
10320 13971973 heart_beep_timer = -1;
10321 13971973 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10322 13971973 }
10323 }
10324
10325
2/2
✓ Branch 0 taken 14333415 times.
✓ Branch 1 taken 1432 times.
14334847 if(rSbtn())
10326 {
10327 1432 int32_t tmp_subscr_clk = frame;
10328
10329 1432 int32_t save_type = 0;
10330
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1424 times.
✗ Branch 3 not taken.
1432 switch(lsave)
10331 {
10332 case 0:
10333 {
10334
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1383 times.
1424 if( FFCore.runScriptedActiveSusbcreen() )
10335 {
10336 41 break;
10337 }
10338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1383 times.
1383 else if ( !stopSubscreenFalling() )
10339 {
10340 1383 conveyclk=3;
10341 1383 dosubscr();
10342 1383 newscr_clk += frame - tmp_subscr_clk;
10343 1383 }
10344 1383 break;
10345 }
10346
10347 case 2:
10348 save_type = 1;
10349 [[fallthrough]];
10350 case 1:
10351
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
10352 7 trigger_save(combobuf[last_savepoint_id], hero_scr);
10353 else save_game((hero_scr->flags4&fSAVEROOM) != 0, save_type); //sanity?
10354 7 break;
10355 }
10356 1432 }
10357
10358
2/2
✓ Branch 0 taken 814154 times.
✓ Branch 1 taken 13520691 times.
14334845 if (!checkstab() )
10359 {
10360 13520691 }
10361
10362 14334845 check_conveyor();
10363 14334845 PhantomsCleanup();
10364 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
10365
2/2
✓ Branch 0 taken 14130462 times.
✓ Branch 1 taken 204383 times.
14334845 if(attack==wHammer)
10366 {
10367
6/8
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 202211 times.
✓ Branch 2 taken 2172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2172 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2167 times.
204383 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
10368 {
10369
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 717 times.
✓ Branch 4 taken 601 times.
2167 switch(dir) //Hero's dir
10370 {
10371 case up:
10372
5/10
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 341 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 341 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 341 times.
✗ Branch 9 not taken.
341 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
10373 341 break;
10374
10375 case down:
10376
5/10
✓ Branch 0 taken 508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 508 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 508 times.
✗ Branch 9 not taken.
508 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
10377 508 break;
10378
10379 case left:
10380
5/10
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 717 times.
✗ Branch 9 not taken.
717 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
10381 717 break;
10382
10383 case right:
10384
5/10
✓ Branch 0 taken 601 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 601 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 601 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 601 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 601 times.
✗ Branch 9 not taken.
601 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
10385 601 break;
10386 }
10387
10388 2167 }
10389 204383 }
10390
10391 14334845 handleSpotlights();
10392
10393
2/2
✓ Branch 0 taken 14334525 times.
✓ Branch 1 taken 320 times.
14334845 if(getOnSideviewLadder())
10394 {
10395
5/8
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311 times.
320 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
10396 {
10397 9 setOnSideviewLadder(false);
10398 9 }
10399
4/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 233 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
311 else if(CANFORCEFACEUP)
10400 {
10401 78 setDir(up);
10402 78 }
10403 320 }
10404
2/2
✓ Branch 0 taken 14064474 times.
✓ Branch 1 taken 270371 times.
14334845 if (justmoved > 0) --justmoved;
10405 14334845 return false;
10406 14336478 }
10407
10408 5284 bool HeroClass::push_pixel(zfix dx, zfix dy)
10409 {
10410 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
10411
3/4
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 2952 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
5284 if(dx && dy)
10412 {
10413 bool r = push_pixel(0,dy);
10414 bool r2 = push_pixel(dx,0);
10415 return r && r2;
10416 }
10417
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 4212 times.
5284 if(dx < 0)
10418 {
10419
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
2144 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
10420
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
1072 || solpush_walkflag(x+dx,y+8,1,this)
10421
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
✓ Branch 2 taken 950 times.
✓ Branch 3 taken 122 times.
1072 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
10422 {
10423 1072 x += dx;
10424 1072 return true;
10425 }
10426 return false;
10427 }
10428
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 2952 times.
4212 else if(dx > 0)
10429 {
10430
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 36 times.
2504 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10431
2/2
✓ Branch 0 taken 1244 times.
✓ Branch 1 taken 16 times.
1260 || solpush_walkflag(x+15+dx,y+8,1,this)
10432
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 1037 times.
✓ Branch 3 taken 207 times.
1244 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10433 {
10434 1224 x += dx;
10435 1224 return true;
10436 }
10437 36 return false;
10438 }
10439
2/2
✓ Branch 0 taken 1378 times.
✓ Branch 1 taken 1574 times.
2952 else if(dy < 0)
10440 {
10441
2/2
✓ Branch 0 taken 1377 times.
✓ Branch 1 taken 1 times.
2755 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10442
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1377 times.
✓ Branch 2 taken 1169 times.
✓ Branch 3 taken 208 times.
1378 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10443 {
10444 1377 y += dy;
10445 1377 return true;
10446 }
10447 1 return false;
10448 }
10449
1/2
✓ Branch 0 taken 1574 times.
✗ Branch 1 not taken.
1574 else if(dy > 0)
10450 {
10451
2/2
✓ Branch 0 taken 1544 times.
✓ Branch 1 taken 30 times.
3118 if(!(solpush_walkflag(x,y+15+dy,2,this)
10452
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1544 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 1354 times.
1574 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10453 {
10454 1544 y += dy;
10455 1544 return true;
10456 }
10457 30 return false;
10458 }
10459 return false;
10460 5284 }
10461 2509 int32_t HeroClass::push_move(zfix dx, zfix dy)
10462 {
10463 2509 int32_t ret = 0;
10464
4/4
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 3579 times.
✓ Branch 2 taken 2509 times.
✓ Branch 3 taken 3402 times.
5911 while(dx || dy)
10465 {
10466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3402 times.
3402 if(check_pitslide() != -1)
10467 break;
10468
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 2952 times.
3402 if(dy)
10469 {
10470
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 2228 times.
2952 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10471 2952 dy -= cy;
10472
2/2
✓ Branch 0 taken 2921 times.
✓ Branch 1 taken 31 times.
2952 if(!push_pixel(0,cy))
10473 {
10474 31 dy = 0;
10475 31 ret |= 2;
10476 31 }
10477 2952 }
10478
2/2
✓ Branch 0 taken 1070 times.
✓ Branch 1 taken 2332 times.
3402 if(dx)
10479 {
10480
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 1777 times.
2332 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10481 2332 dx -= cx;
10482
2/2
✓ Branch 0 taken 2296 times.
✓ Branch 1 taken 36 times.
2332 if(!push_pixel(cx,0))
10483 {
10484 36 dx = 0;
10485 36 ret |= 1;
10486 36 }
10487 2332 }
10488 }
10489 2509 return ret;
10490 }
10491
10492 14309111 bool HeroClass::setSolid(bool set)
10493 {
10494
1/2
✓ Branch 0 taken 14309111 times.
✗ Branch 1 not taken.
14309111 bool actual = set && !toogam; //not solid when noclipping
10495 14309111 bool ret = solid_object::setSolid(actual);
10496 14309111 solid = set;
10497 14309111 return ret;
10498 }
10499
10500 18082 void HeroClass::solid_push(solid_object* obj)
10501 {
10502
1/2
✓ Branch 0 taken 18082 times.
✗ Branch 1 not taken.
18082 if(obj == this) return; //can't push self
10503
10504 18082 zfix dx, dy;
10505 18082 int32_t hdir = -1;
10506 18082 solid_push_int(obj,dx,dy,hdir,!on_ffc_platform());
10507
10508
4/4
✓ Branch 0 taken 17992 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 17756 times.
✓ Branch 3 taken 236 times.
18082 if(!dx && !dy) return;
10509
10510 326 obj->doContactDamage(hdir);
10511
10512 326 bool t = obj->getTempNonsolid();
10513 326 obj->setTempNonsolid(true);
10514
10515 326 push_move(dx,dy);
10516
10517 326 obj->setTempNonsolid(t);
10518 18082 }
10519
10520 #define COND_AWPN (get_qr(qr_SELECTAWPN) ? game->awpn : 255)
10521 #define COND_BWPN (game->bwpn)
10522 #define COND_XWPN (get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : 255)
10523 #define COND_YWPN (get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : 255)
10524 //Helper function
10525 1330 static void deselectbombsWPN(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN,
10526 word f1 = 255, word f2 = 255, word f3 = 255)
10527 {
10528 1330 byte pgn = wpos&0xFF, pos = wpos>>8;
10529 1330 bool empty = pgn==255;
10530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1330 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
10531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
1330 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
10532
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 if(!pg)
10533 {
10534 wpos = 255; //set to nothingness
10535 return;
10536 }
10537
10538
4/6
✓ Branch 0 taken 1309 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
1330 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
10539
1/6
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
10540
1/6
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
10541 1330 auto temp = pg->movepos_legacy(SEL_VERIFY_LEFT, wpos, fp1, fp2, fp3);
10542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
1330 if((temp&0xFF) == 0xFF)
10543 BTNwpn = -1;
10544 1330 else BTNwpn = pg->get_item_pos(temp>>8);
10545
2/2
✓ Branch 0 taken 1328 times.
✓ Branch 1 taken 2 times.
1330 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
10546 1330 wpos = temp;
10547 1330 }
10548 // A routine used exclusively by startwpn,
10549 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10550 1379 void HeroClass::deselectbombs(int32_t super)
10551 {
10552
6/10
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 1347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1347 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1347 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1347 times.
1379 if ( get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10553
4/6
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 1330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1330 times.
✗ Branch 5 not taken.
1347 if(getItemFamily(itemsbuf,Bwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10554 {
10555
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 if(!new_subscreen_active)
10556 return;
10557
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1330 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1330 times.
1330 deselectbombsWPN(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
10558 1330 }
10559
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Xwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10560 {
10561 if(!new_subscreen_active)
10562 return;
10563 deselectbombsWPN(game->xwpn, Xwpn, directItemX, COND_AWPN, COND_BWPN, COND_YWPN);
10564 }
10565
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Ywpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10566 {
10567 if(!new_subscreen_active)
10568 return;
10569 deselectbombsWPN(game->ywpn, Ywpn, directItemY, COND_AWPN, COND_XWPN, COND_BWPN);
10570 }
10571
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Awpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Awpn==directWpn))
10572 {
10573 if(!new_subscreen_active)
10574 return;
10575 deselectbombsWPN(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
10576 }
10577 1379 }
10578
10579 int32_t potion_life=0;
10580 int32_t potion_magic=0;
10581
10582 13697853 bool HeroClass::onWater(bool drownonly)
10583 {
10584 13697853 int32_t water = 0;
10585 13697853 int32_t types[4] = {0};
10586 13697853 int32_t x1 = x+4, x2 = x+11,
10587 13697853 y1 = y+9, y2 = y+15;
10588
2/2
✓ Branch 0 taken 1111229 times.
✓ Branch 1 taken 12586624 times.
13697853 if (get_qr(qr_SMARTER_WATER))
10589 {
10590
4/4
✓ Branch 0 taken 10733 times.
✓ Branch 1 taken 1100496 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8349 times.
1119600 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
10591
2/2
✓ Branch 0 taken 9619 times.
✓ Branch 1 taken 1114 times.
10733 iswaterex_z3(0, -1, x1, y2, true, false) &&
10592
2/2
✓ Branch 0 taken 8371 times.
✓ Branch 1 taken 1248 times.
9619 iswaterex_z3(0, -1, x2, y1, true, false) &&
10593 8371 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10594 1111229 }
10595 else
10596 {
10597 12586624 types[0] = COMBOTYPE(x1,y1);
10598
10599
2/2
✓ Branch 0 taken 12463002 times.
✓ Branch 1 taken 123622 times.
12586624 if(MAPFFCOMBO(x1,y1))
10600 123622 types[0] = FFCOMBOTYPE(x1,y1);
10601
10602 12586624 types[1] = COMBOTYPE(x1,y2);
10603
10604
2/2
✓ Branch 0 taken 12477770 times.
✓ Branch 1 taken 108854 times.
12586624 if(MAPFFCOMBO(x1,y2))
10605 108854 types[1] = FFCOMBOTYPE(x1,y2);
10606
10607 12586624 types[2] = COMBOTYPE(x2,y1);
10608
10609
2/2
✓ Branch 0 taken 12461789 times.
✓ Branch 1 taken 124835 times.
12586624 if(MAPFFCOMBO(x2,y1))
10610 124835 types[2] = FFCOMBOTYPE(x2,y1);
10611
10612 12586624 types[3] = COMBOTYPE(x2,y2);
10613
10614
2/2
✓ Branch 0 taken 12474638 times.
✓ Branch 1 taken 111986 times.
12586624 if(MAPFFCOMBO(x2,y2))
10615 111986 types[3] = FFCOMBOTYPE(x2,y2);
10616
10617 12586624 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10618
2/2
✓ Branch 0 taken 12468344 times.
✓ Branch 1 taken 118280 times.
12586624 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10619 118280 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10620
10621
5/6
✓ Branch 0 taken 223094 times.
✓ Branch 1 taken 12363530 times.
✓ Branch 2 taken 214289 times.
✓ Branch 3 taken 8805 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205928 times.
12792552 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10622
4/4
✓ Branch 0 taken 206169 times.
✓ Branch 1 taken 8120 times.
✓ Branch 2 taken 205928 times.
✓ Branch 3 taken 241 times.
214289 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10623 205928 water = typec;
10624 }
10625
2/2
✓ Branch 0 taken 13483576 times.
✓ Branch 1 taken 214277 times.
13697853 if(water > 0)
10626 {
10627
1/2
✓ Branch 0 taken 214277 times.
✗ Branch 1 not taken.
214277 if(!drownonly) return true;
10628
7/8
✓ Branch 0 taken 139216 times.
✓ Branch 1 taken 75061 times.
✓ Branch 2 taken 139213 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2249 times.
✓ Branch 5 taken 136964 times.
✓ Branch 6 taken 2249 times.
✗ Branch 7 not taken.
214277 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
10629 {
10630 75064 return true;
10631 }
10632 139213 }
10633 13622789 return false;
10634 13697853 }
10635
10636 bool HeroClass::mirrorBonk()
10637 {
10638 zfix tx = x, ty = y, tz = z;
10639 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10640 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10641 execute(info);
10642 bool fail = info.isUnwalkable();
10643
10644 if(!fail) //not solid, but check for water/pits...
10645 {
10646 if(onWater(true))
10647 fail = true;
10648 if(pitslide() || fallclk)
10649 fail = true;
10650 fallclk = 0;
10651 }
10652 x = tx; y = ty; z = tz;
10653 return fail;
10654 }
10655
10656 void HeroClass::doMirror(int32_t mirrorid)
10657 {
10658 if(z > 0 || fakez > 0) return; //No mirror in air
10659 if(mirrorid < 0)
10660 mirrorid = current_item_id(itype_mirror);
10661 if(mirrorid < 0) return;
10662
10663 if((hero_scr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10664 {
10665 item_error();
10666 return;
10667 }
10668 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10669 rpos_t rposes[] = {COMBOPOS_REGION_B(x+sens,y+sens), COMBOPOS_REGION_B(x+sens,y+15-sens),
10670 COMBOPOS_REGION_B(x+15-sens,y+sens), COMBOPOS_REGION_B(x+15-sens,y+15-sens)};
10671 for(auto rpos : rposes)
10672 {
10673 if (rpos == rpos_t::None)
10674 continue;
10675
10676 if(HASFLAG_ANY(mfNOMIRROR, rpos)) //"No Mirror" flag touching the player
10677 {
10678 item_error();
10679 return;
10680 }
10681 }
10682
10683 itemdata const& mirror = itemsbuf[mirrorid];
10684 if(DMaps[cur_dmap].flags & dmfMIRRORCONTINUE)
10685 {
10686 paymagiccost(mirrorid);
10687 if(mirror.usesound2) sfx(mirror.usesound2);
10688
10689 doWarpEffect(mirror.misc2, true);
10690 if(mirror.flags & item_flag2) //Act as F6->Continue
10691 {
10692 Quit = qCONT;
10693 skipcont = 1;
10694 }
10695 else //Act as Divine Escape
10696 {
10697 int32_t div_prot_temp=div_prot_item;
10698 restart_level();
10699 div_prot_item=div_prot_temp;
10700 magicitem=-1;
10701 magiccastclk=0;
10702 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10703 }
10704 }
10705 else
10706 {
10707 int32_t destdmap = DMaps[cur_dmap].mirrorDMap;
10708 int32_t offscr = cur_screen - DMaps[cur_dmap].xoff;
10709 if(destdmap < 0)
10710 return;
10711 int32_t destscr = DMaps[destdmap].xoff + offscr;
10712 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10713 return;
10714 paymagiccost(mirrorid);
10715
10716 //Store some values to restore if 'warp fails'
10717 int32_t tLastEntrance = lastentrance,
10718 tLastEntranceDMap = lastentrance_dmap,
10719 tContScr = game->get_continue_scrn(),
10720 tContDMap = game->get_continue_dmap(),
10721 tPortalDMap = game->saved_mirror_portal.srcdmap;
10722 int32_t sourcescr = cur_screen, sourcedmap = cur_dmap;
10723 zfix tx = x, ty = y, tz = z;
10724 game->saved_mirror_portal.srcdmap = -1;
10725 action = none; FFCore.setHeroAction(none);
10726
10727 //Warp to new dmap
10728 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10729 mirror.usesound, 0, -1);
10730
10731 //Check for valid landing location
10732 if(mirrorBonk()) //Invalid landing, warp back!
10733 {
10734 action = none; FFCore.setHeroAction(none);
10735 lastentrance = tLastEntrance;
10736 lastentrance_dmap = tLastEntranceDMap;
10737 game->set_continue_scrn(tContScr);
10738 game->set_continue_dmap(tContDMap);
10739 x = tx;
10740 y = ty;
10741 z = tz;
10742 game->saved_mirror_portal.srcdmap = tPortalDMap;
10743 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10744 mirror.usesound, 0, -1);
10745 }
10746 else if(mirror.flags & item_flag1) //Place portal!
10747 {
10748 //Place the portal
10749 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10750 //Since it was placed after loading this screen, load the portal object now
10751 game->load_portal();
10752 //Don't immediately trigger the warp back
10753 mirror_portal.prox_active = false;
10754
10755 //Set continue point
10756 if(cur_dmap != game->get_continue_dmap())
10757 {
10758 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
10759 }
10760 game->set_continue_dmap(cur_dmap);
10761 lastentrance_dmap = cur_dmap;
10762 lastentrance = game->get_continue_scrn();
10763 }
10764 }
10765 }
10766
10767 14307783 void HeroClass::handle_passive_buttons()
10768 {
10769 14307783 do_liftglove(-1,true);
10770 14307783 do_jump(-1,true);
10771 14307783 }
10772
10773 3777 void HeroClass::land_on_ground()
10774 {
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3777 times.
3777 if (fakez<0) fakez = 0;
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3777 times.
3777 if (z<0) z = 0;
10777
10778 3777 bool played_land_sfx = false;
10779
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 3716 times.
3777 if(get_qr(qr_OLD_LANDING_SFX))
10780 {
10781
9/10
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 409 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 399 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3694 times.
✓ Branch 9 taken 22 times.
4125 if(!sideview_mode() && ((iswaterex_z3(MAPCOMBO(x,y+8), -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER))
10782 22 sfx(WAV_ZN1SPLASH,x.getInt());
10783 3716 played_land_sfx = true;
10784 3716 }
10785
10786 3777 auto rpos = COMBOPOS_REGION_B(x+8, y+(sideview_mode()?16:12));
10787
2/2
✓ Branch 0 taken 3770 times.
✓ Branch 1 taken 26397 times.
30167 for (int q = 0; q < 7; ++q)
10788 {
10789
2/2
✓ Branch 0 taken 26390 times.
✓ Branch 1 taken 7 times.
26397 if (rpos == rpos_t::None) break;
10790
10791 26390 auto rpos_handle = get_rpos_handle(rpos, q);
10792 26390 auto& cmb = rpos_handle.combo();
10793 26390 byte csfx = cmb.sfx_landing;
10794
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 26363 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
26390 if (csfx && !get_qr(qr_OLD_LANDING_SFX))
10795 {
10796 sfx(csfx, x.getInt());
10797 played_land_sfx = true;
10798 }
10799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26390 times.
26602 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10800 212 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDHERE);
10801 });
10802 26390 }
10803
10804
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 3716 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
3777 if(!played_land_sfx && QMisc.miscsfx[sfxHERO_LANDS])
10805 sfx(QMisc.miscsfx[sfxHERO_LANDS], x.getInt());
10806
10807
10808 1852129 for_some_rpos([&](const rpos_handle_t& rpos_handle) {
10809
1/2
✓ Branch 0 taken 1848352 times.
✗ Branch 1 not taken.
1872908 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10810 24556 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDANYWHERE);
10811 });
10812
10813 1848352 return true;
10814 });
10815 117695 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
10816
1/2
✓ Branch 0 taken 113918 times.
✗ Branch 1 not taken.
113918 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
10817 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDANYWHERE);
10818 });
10819
10820 113918 return true;
10821 });
10822 3777 }
10823
10824 static bool did_passive_jump = false;
10825 14308152 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10826 {
10827
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 14307783 times.
14308152 if(passive) did_passive_jump = false;
10828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
369 else if(did_passive_jump) return false; //don't jump twice in the same frame
10829
10830
2/2
✓ Branch 0 taken 610313 times.
✓ Branch 1 taken 13697839 times.
14308152 if(nomove_action(action)) return false; //can't jump while ex. drowning
10831
2/2
✓ Branch 0 taken 75064 times.
✓ Branch 1 taken 13622775 times.
13697839 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10832
10833
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 13622408 times.
13622775 if(jumpid < 0)
10834 13622408 jumpid = current_item_id(itype_rocs,true,true);
10835
10836
2/2
✓ Branch 0 taken 13235630 times.
✓ Branch 1 taken 387145 times.
13622775 if(unsigned(jumpid) >= MAXITEMS) return false;
10837
4/4
✓ Branch 0 taken 385918 times.
✓ Branch 1 taken 1227 times.
✓ Branch 2 taken 1935 times.
✓ Branch 3 taken 383983 times.
387145 if(inlikelike || charging) return false;
10838
1/2
✓ Branch 0 taken 383983 times.
✗ Branch 1 not taken.
383983 if(!checkitem_jinx(jumpid)) return false;
10839
10840 383983 itemdata const& itm = itemsbuf[jumpid];
10841
10842 383983 bool standing = isStanding(true);
10843
3/4
✓ Branch 0 taken 370060 times.
✓ Branch 1 taken 13923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13923 times.
383983 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10844
4/6
✓ Branch 0 taken 383983 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13923 times.
✓ Branch 3 taken 370060 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13923 times.
383983 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10845
2/4
✓ Branch 0 taken 370060 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 370060 times.
370060 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10846 {
10847 item_error();
10848 return false;
10849 }
10850
10851 370060 byte intbtn = byte(itm.misc2&0xFF);
10852
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 369708 times.
370060 if(passive)
10853 {
10854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369708 times.
369708 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10855 369708 return false; //not pressed
10856 }
10857
10858 352 paymagiccost(jumpid);
10859
10860
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(!standing)
10861 {
10862 ++extra_jump_count;
10863 fall = 0;
10864 fakefall = 0;
10865 if(hoverclk > 0)
10866 hoverclk = -hoverclk;
10867 }
10868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 if(itm.flags & item_flag1)
10869 setFall(fall - itm.power);
10870 352 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10871 352 coyotetime = 65535; //jumped, so no coyotetime
10872 352 setOnSideviewLadder(false);
10873
10874 // Reset the ladder, unless on an unwalkable combo
10875
6/10
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 352 times.
✗ Branch 9 not taken.
352 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,STANDING_Z_STATE)))
10876 reset_ladder();
10877
10878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 if(itm.usesound)
10879 352 sfx(itm.usesound,pan(x.getInt()));
10880
10881
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(passive)
10882 {
10883 did_passive_jump = true;
10884 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10885 }
10886 352 return true;
10887 14308152 }
10888 11720 void HeroClass::drop_liftwpn()
10889 {
10890
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11719 times.
11720 if(!lift_wpn) return;
10891
10892 1 handle_lift(false); //sets position properly, accounting for large weapons
10893
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int liftid = last_lift_id ? *last_lift_id : current_item_id(itype_liftglove,true,true);
10894 1 itemdata const& glove = itemsbuf[liftid];
10895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(isSideViewGravity())
10896 {
10897 lift_wpn->moveflags |= move_no_fake_z;
10898 }
10899 else
10900 {
10901 1 auto lheight = liftheight+z+fakez;
10902
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(glove.flags & item_flag1)
10903 {
10904 lift_wpn->z = 0;
10905 lift_wpn->fakez = lheight;
10906 lift_wpn->moveflags |= move_no_real_z;
10907 }
10908 else
10909 {
10910 1 lift_wpn->z = lheight;
10911 1 lift_wpn->moveflags |= move_no_fake_z;
10912 }
10913 }
10914 1 lift_wpn->dir = dir;
10915 1 lift_wpn->step = 0;
10916 1 lift_wpn->fakefall = 0;
10917 1 lift_wpn->fall = 0;
10918 1 Lwpns.add(lift_wpn);
10919 1 lift_wpn = nullptr;
10920 11720 }
10921 14307783 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10922 {
10923
2/2
✓ Branch 0 taken 10406 times.
✓ Branch 1 taken 14297377 times.
14307783 if(!lift_wpn)
10924 14297377 last_lift_id.reset();
10925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307783 times.
14307783 if(liftid < 0)
10926 {
10927
4/4
✓ Branch 0 taken 9569 times.
✓ Branch 1 taken 14298214 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 8880 times.
14307783 if(last_lift_id && can_lift(*last_lift_id))
10928 8880 liftid = *last_lift_id;
10929 14298903 else liftid = current_item_id(itype_liftglove,true,true);
10930 14307783 }
10931
2/2
✓ Branch 0 taken 362622 times.
✓ Branch 1 taken 13945161 times.
14307783 if(!can_lift(liftid)) return;
10932 362622 itemdata const& glove = itemsbuf[liftid];
10933 362622 byte intbtn = byte(glove.misc1&0xFF);
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362622 times.
362622 if(passive)
10935 {
10936
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 360374 times.
362622 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10937 360374 return; //not pressed
10938 2248 }
10939
10940 2248 bool had_weapon = lift_wpn;
10941
10942
3/4
✓ Branch 0 taken 2187 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 2187 times.
✗ Branch 3 not taken.
4435 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10943
1/2
✓ Branch 0 taken 2187 times.
✗ Branch 1 not taken.
2187 (checkbunny(liftid) && checkmagiccost(liftid))))
10944 {
10945 item_error();
10946 return;
10947 }
10948
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2248 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
10949 return;
10950
10951 2248 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10952
1/2
✓ Branch 0 taken 2248 times.
✗ Branch 1 not taken.
2248 if(glove.script)
10953 {
10954 if(!paidmagic)
10955 {
10956 paidmagic = true;
10957 paymagiccost(liftid);
10958 }
10959
10960 int i = liftid;
10961 FFCore.reset_script_engine_data(ScriptType::Item, i);
10962 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
10963 FFCore.deallocateAllScriptOwned(ScriptType::Item,i);
10964
10965 bool has_weapon = lift_wpn;
10966 if(has_weapon != had_weapon) //Item action script changed the lift information
10967 {
10968 if(passive)
10969 {
10970 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10971 }
10972 return;
10973 }
10974 }
10975
10976
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 2187 times.
2248 if(lift_wpn)
10977 {
10978
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!paidmagic)
10979 {
10980 paidmagic = true;
10981 paymagiccost(liftid);
10982 }
10983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!liftclk)
10984 {
10985 //Throw the weapon!
10986 //hero's direction and position
10987 61 handle_lift(false); //sets position properly, accounting for large weapons
10988
10989 61 lift_wpn->dir = dir;
10990
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(lift_wpn->angular)
10991 lift_wpn->angle = WrapAngle(DirToRadians(dir));
10992
10993 61 lift_wpn->doAutoRotate(false, true);
10994 //Configured throw speed in both axes
10995 61 auto basestep = glove.misc2;
10996 61 lift_wpn->step = zfix(basestep)/100;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(isSideViewGravity())
10999 {
11000 lift_wpn->fall = -glove.misc3;
11001 switch(dir)
11002 {
11003 case left: case right:
11004 break; //nothing special for sideways
11005 case up: //step converts to upwards fall
11006 lift_wpn->fall -= basestep;
11007 lift_wpn->step = 0;
11008 break;
11009 case down: //step converts into straight down fall
11010 lift_wpn->fall = zc_min(basestep,zinit.terminalv);
11011 lift_wpn->step = 0;
11012 break;
11013 }
11014 lift_wpn->moveflags |= move_no_fake_z;
11015 }
11016 else
11017 {
11018 61 auto lheight = liftheight+z+fakez;
11019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(glove.flags & item_flag1)
11020 {
11021 lift_wpn->z = 0;
11022 lift_wpn->fakez = lheight;
11023 lift_wpn->fakefall = -glove.misc3;
11024 lift_wpn->moveflags |= move_no_real_z;
11025 }
11026 else
11027 {
11028 61 lift_wpn->z = lheight;
11029 61 lift_wpn->fall = -glove.misc3;
11030 61 lift_wpn->moveflags |= move_no_fake_z;
11031 }
11032 }
11033 61 Lwpns.add(lift_wpn);
11034 61 lift_wpn = nullptr;
11035 61 last_lift_id.reset();
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(glove.usesound2)
11037 61 sfx(glove.usesound2,pan(int32_t(x)));
11038 61 }
11039 else last_lift_id = liftid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(passive)
11042 {
11043 61 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11044 61 }
11045 61 return;
11046 }
11047
11048 2187 bool lifted = false;
11049 //Check for a liftable weapon
11050 //if(!lifted)
11051 {
11052 2187 zfix hx, hy, hw, hh;
11053
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 670 times.
✓ Branch 4 taken 597 times.
2187 switch(dir)
11054 {
11055 case up:
11056 340 hx = x;
11057 340 hy = y-8;
11058 340 hw = 16;
11059 340 hh = bigHitbox ? 8 : 16;
11060 340 break;
11061 case down:
11062 580 hx = x;
11063 580 hy = y+16;
11064 580 hw = 16;
11065 580 hh = 8;
11066 580 break;
11067 case left:
11068 670 hx = x-8;
11069 670 hy = y;
11070 670 hw = 8;
11071 670 hh = 16;
11072 670 break;
11073 case right:
11074 597 hx = x+16;
11075 597 hy = y;
11076 597 hw = 8;
11077 597 hh = 16;
11078 597 break;
11079 }
11080
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 113 times.
2298 for(int32_t q = 0; q < Lwpns.Count(); ++q)
11081 {
11082 113 weapon* w = (weapon*)Lwpns.spr(q);
11083
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113 if((w->lift_level && w->lift_level <= glove.fam_type))
11084 {
11085 7 auto tmpflags = w->misc_wflags;
11086 7 w->misc_wflags &= ~WFLAG_NO_COLL_WHEN_STILL;
11087 7 bool hit = w->hit(hx,hy,0,hw,hh,1);
11088 7 w->misc_wflags = tmpflags;
11089
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(!hit)
11090 5 continue;
11091
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(glove.usesound)
11092 2 sfx(glove.usesound,pan(x));
11093 2 lift(w, w->lift_time, w->lift_height);
11094 2 Lwpns.remove(w);
11095 2 lifted = true;
11096 2 break;
11097 }
11098 106 }
11099 }
11100
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2185 times.
2187 if(!lifted) //Check for a liftable combo
11101 {
11102 2185 zfix bx, by;
11103 2185 zfix bx2, by2;
11104
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 670 times.
✓ Branch 4 taken 595 times.
2185 switch(dir)
11105 {
11106 case up:
11107 340 by = y + (bigHitbox ? -2 : 6);
11108 340 by2 = by;
11109 340 bx = x + 4;
11110 340 bx2 = bx + 8;
11111 340 break;
11112 case down:
11113 580 by = y + 17;
11114 580 by2 = by;
11115 580 bx = x + 4;
11116 580 bx2 = bx + 8;
11117 580 break;
11118 case left:
11119 670 by = y + (bigHitbox ? 0 : 8);
11120 670 by2 = y + 8;
11121 670 bx = x - 2;
11122 670 bx2 = x - 2;
11123 670 break;
11124 case right:
11125 595 by = y + (bigHitbox ? 0 : 8);
11126 595 by2 = y + 8;
11127 595 bx = x + 17;
11128 595 bx2 = x + 17;
11129 595 break;
11130 }
11131 2185 rpos_t rpos = COMBOPOS_REGION_B(bx, by);
11132 2185 rpos_t rpos2 = COMBOPOS_REGION_B(bx2, by2);
11133
11134
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 15271 times.
17413 for(auto lyr = 6; lyr >= 0; --lyr)
11135 {
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15271 times.
15271 if(rpos != rpos_t::None)
11137 {
11138 15271 auto rpos_handle = get_rpos_handle(rpos, lyr);
11139 15271 auto& cmb = rpos_handle.combo();
11140
2/2
✓ Branch 0 taken 15231 times.
✓ Branch 1 taken 40 times.
15271 if(cmb.liftflags & LF_LIFTABLE)
11141 {
11142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(do_lift_combo(rpos_handle,liftid))
11143 {
11144 40 lifted = true;
11145 40 break;
11146 }
11147 }
11148 15231 }
11149
3/4
✓ Branch 0 taken 2139 times.
✓ Branch 1 taken 13092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2139 times.
15231 if(rpos != rpos2 && rpos2 != rpos_t::None)
11150 {
11151 2139 auto rpos_handle_2 = get_rpos_handle(rpos2, lyr);
11152 2139 newcombo const& cmb2 = combobuf[rpos_handle_2.data()];
11153
2/2
✓ Branch 0 taken 2136 times.
✓ Branch 1 taken 3 times.
2139 if(cmb2.liftflags & LF_LIFTABLE)
11154 {
11155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(do_lift_combo(rpos_handle_2,liftid))
11156 {
11157 3 lifted = true;
11158 3 break;
11159 }
11160 }
11161 2136 }
11162 15228 }
11163 2185 }
11164
11165
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2142 times.
2187 if(!lifted)
11166 {
11167 2142 last_lift_id.reset();
11168 2142 return;
11169 }
11170 45 last_lift_id = liftid;
11171
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!paidmagic)
11173 {
11174 45 paidmagic = true;
11175 45 paymagiccost(liftid);
11176 45 }
11177 45 set_liftflags(liftid);
11178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(passive)
11179 45 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
11180 45 return;
11181 14307783 }
11182 21661 void HeroClass::handle_lift(bool dec)
11183 {
11184
1/2
✓ Branch 0 taken 21661 times.
✗ Branch 1 not taken.
21661 if(lift_wpn)
11185 {
11186 21661 lift_wpn->fakez = 0;
11187 21661 lift_wpn->dir = dir;
11188 21661 }
11189 else liftclk = 0;
11190
11191
2/2
✓ Branch 0 taken 19896 times.
✓ Branch 1 taken 1765 times.
21661 if(liftclk <= (dec?1:0))
11192 {
11193 19896 liftclk = 0;
11194 19896 tliftclk = 0;
11195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19896 times.
19896 if(lift_wpn)
11196 {
11197
2/4
✓ Branch 0 taken 19896 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19896 times.
19896 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
11198 {
11199 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
11200 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
11201 }
11202 else
11203 {
11204 19896 lift_wpn->x = x;
11205 19896 lift_wpn->y = y;
11206 }
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19896 times.
19896 if(isSideViewGravity())
11208 lift_wpn->y -= liftheight;
11209 19896 else lift_wpn->z = liftheight;
11210 19896 }
11211
2/2
✓ Branch 0 taken 19834 times.
✓ Branch 1 taken 62 times.
19896 if(action == lifting)
11212 {
11213 62 action = none; FFCore.setHeroAction(none);
11214 62 }
11215 19896 return;
11216 }
11217
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 874 times.
1765 if(dec) --liftclk;
11218 double xdist, ydist;
11219 1765 double perc = (liftclk/double(tliftclk));
11220
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 514 times.
✓ Branch 4 taken 678 times.
1765 switch(dir)
11221 {
11222 case up:
11223 {
11224 318 xdist = 0;
11225 318 ydist = -16;
11226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(lift_wpn->txsz > 1)
11227 {
11228 xdist = -((lift_wpn->txsz*8)-8);
11229 }
11230 318 else xdist = 0;
11231
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(lift_wpn->tysz > 1)
11232 {
11233 ydist = -(lift_wpn->tysz*16);
11234 }
11235 318 ydist *= perc;
11236 318 break;
11237 }
11238 case down:
11239 {
11240 255 xdist = 0;
11241 255 ydist = 16;
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if(lift_wpn->txsz > 1)
11243 {
11244 xdist = -((lift_wpn->txsz*8)-8);
11245 }
11246 255 else xdist = 0;
11247 255 ydist *= perc;
11248 255 break;
11249 }
11250 case left:
11251 {
11252 514 xdist = -16;
11253 514 ydist = 0;
11254
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
514 if(lift_wpn->txsz > 1)
11255 {
11256 xdist = -(lift_wpn->txsz*16);
11257 }
11258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
514 if(lift_wpn->tysz > 1)
11259 {
11260 ydist = -((lift_wpn->tysz*8)-8);
11261 }
11262 514 else ydist = 0;
11263 514 xdist *= perc;
11264 514 break;
11265 }
11266 case right:
11267 {
11268 678 xdist = 16;
11269 678 ydist = 0;
11270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 678 times.
678 if(lift_wpn->tysz > 1)
11271 {
11272 ydist = -((lift_wpn->tysz*8)-8);
11273 }
11274 678 else ydist = 0;
11275 678 xdist *= perc;
11276 678 break;
11277 }
11278 }
11279
11280 1765 lift_wpn->x = x + xdist;
11281 1765 lift_wpn->y = y + ydist;
11282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(isSideViewGravity())
11283 lift_wpn->y -= liftheight*(1.0-perc);
11284 1765 else lift_wpn->z = liftheight*(1.0-perc);
11285 21661 }
11286 14317395 bool HeroClass::can_lift(int32_t gloveid)
11287 {
11288
2/2
✓ Branch 0 taken 13881881 times.
✓ Branch 1 taken 435514 times.
14317395 if(unsigned(gloveid) >= MAXITEMS) return false;
11289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435514 times.
435514 if(lstunclock) return false;
11290
1/2
✓ Branch 0 taken 435514 times.
✗ Branch 1 not taken.
435514 if(!checkitem_jinx(gloveid)) return false;
11291 435514 itemdata const& glove = itemsbuf[gloveid];
11292
3/3
✓ Branch 0 taken 371545 times.
✓ Branch 1 taken 57216 times.
✓ Branch 2 taken 6753 times.
435514 switch(action)
11293 {
11294 case none: case walking:
11295 371545 break;
11296
11297 case swimming:
11298
1/2
✓ Branch 0 taken 6753 times.
✗ Branch 1 not taken.
6753 if(glove.flags & item_flag2)
11299 break;
11300 6753 return false;
11301
11302 default:
11303 57216 return false;
11304 }
11305 371545 return true;
11306 14317395 }
11307 62 void HeroClass::lift(weapon* w, byte timer, zfix height)
11308 {
11309 62 lift_wpn = w;
11310 62 liftclk = timer;
11311 62 tliftclk = timer;
11312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(height < 0)
11313 liftheight = 0;
11314 62 else liftheight = height;
11315 62 }
11316
11317 15406 void HeroClass::check_on_hit() // Called when the player is hit
11318 {
11319
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15395 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
15406 if(lift_wpn && (liftflags & LIFTFL_DROP_ON_HIT))
11320 drop_liftwpn();
11321 15406 }
11322
11323 137 void HeroClass::doSwitchHook(byte style)
11324 {
11325 137 hs_switcher = true;
11326 137 pull_hero = true;
11327 //{ Load hook weapons, set them to obey special drawing
11328 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
11329 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
11330
11331
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(w)
11332 1 w->switch_hooked = true;
11333
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(hw)
11334 1 hw->switch_hooked = true;
11335
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 137 times.
142 for(int32_t j=0; j<chainlinks.Count(); j++)
11336 {
11337 5 chainlinks.spr(j)->switch_hooked = true;
11338 5 }
11339 //}
11340 137 rpos_t plrpos = COMBOPOS_REGION_B(x+8, y+8);
11341
3/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
137 if(hooked_comborpos != rpos_t::None && plrpos != rpos_t::None)
11342 {
11343
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11344 132 hooked_layerbits = 0;
11345
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = 0; q < 7; ++q)
11346 924 hooked_undercombos[q] = -1;
11347
11348 132 int target_pos = RPOS_TO_POS(hooked_comborpos);
11349 132 int player_pos = RPOS_TO_POS(plrpos);
11350
11351
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = max_layer; q > -1; --q)
11352 {
11353 924 auto target_pos_handle = get_rpos_handle(hooked_comborpos, q);
11354 924 auto player_pos_handle = get_rpos_handle(plrpos, q);
11355
11356 924 mapscr* player_scr = player_pos_handle.scr;
11357 924 mapscr* target_scr = target_pos_handle.scr;
11358
11359 924 newcombo const& cmb = combobuf[target_scr->data[target_pos]];
11360 924 newcombo const& comb2 = combobuf[player_scr->data[player_pos]];
11361 924 int32_t fl1 = target_scr->sflag[target_pos],
11362 924 fl2 = player_scr->sflag[player_pos];
11363 924 bool isPush = false;
11364
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(isSwitchHookable(cmb))
11365 {
11366
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK)
11367 {
11368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if((cmb.usrflags&cflag1) && player_scr->data[player_pos])
11369 continue; //don't swap with non-zero combo
11370
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 132 times.
132 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
11371 continue; //too low a switchhook level
11372 132 hooked_layerbits |= 1<<q; //Swapping
11373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3)
11374 {
11375 if(cmb.usrflags&cflag6)
11376 {
11377 hooked_undercombos[q] = target_scr->data[target_pos]+1;
11378 hooked_undercombos[q+7] = target_scr->cset[target_pos];
11379 }
11380 else
11381 {
11382 hooked_undercombos[q] = target_scr->undercombo;
11383 hooked_undercombos[q+7] = target_scr->undercset;
11384 }
11385 }
11386 else
11387 {
11388 132 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11389
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
11390 isPush = true;
11391 }
11392 132 }
11393 else if(isCuttableType(cmb.type))
11394 {
11395 if(isCuttableNextType(cmb.type))
11396 {
11397 hooked_undercombos[q] = target_scr->data[target_pos]+1;
11398 hooked_undercombos[q+7] = target_scr->cset[target_pos];
11399 }
11400 else
11401 {
11402 hooked_undercombos[q] = target_scr->undercombo;
11403 hooked_undercombos[q+7] = target_scr->undercset;
11404 }
11405 hooked_layerbits |= 1<<q; //Swapping
11406 }
11407 else
11408 {
11409 hooked_layerbits |= 1<<q; //Swapping
11410 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11411 }
11412 132 }
11413
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
11414 {
11415
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
✗ Branch 5 not taken.
132 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
11416 132 && hasMainGuy(target_scr->screen))
11417 {
11418 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
11419 continue;
11420 }
11421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(fl1 == mfPUSHED)
11422 {
11423 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
11424 continue;
11425 }
11426
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(fl1)
11427 {
11428 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11429 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11430 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11431 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11432 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11433 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11434 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11435 isPush = true;
11436 132 }
11437
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
11438 {
11439 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11440 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11441 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11442 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11443 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11444 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11445 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11446 isPush = true;
11447 132 }
11448
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(isPush) //Check for block holes / triggers
11449 {
11450 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
11451 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
11452 {
11453 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11454 }
11455 else if(!get_qr(qr_BLOCKHOLE_SAME_ONLY))
11456 {
11457 auto maxLayer = get_qr(qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
11458 for(auto lyr = 0; lyr < maxLayer; ++lyr)
11459 {
11460 if(lyr == q) continue;
11461 switch(player_scr->sflag[player_pos])
11462 {
11463 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11464 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11465 lyr=7;
11466 break;
11467 }
11468 switch(combobuf[player_scr->data[player_pos]].flag)
11469 {
11470 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11471 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11472 lyr=7;
11473 break;
11474 }
11475 }
11476 }
11477 }
11478 132 }
11479 924 }
11480 132 }
11481 137 switch_hooked = true;
11482 137 switchhookstyle = style;
11483
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
137 switch(style)
11484 {
11485 default: case swPOOF:
11486 {
11487 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
11488
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
11489
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_comborpos != rpos_t::None)
11491 {
11492 auto [decx, decy] = COMBOXY_REGION(hooked_comborpos);
11493 decorations.add(new comboSprite(decx, decy, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11494 }
11495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
11496
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11497 1 break;
11498 }
11499 case swFLICKER:
11500 {
11501 136 switchhookmaxtime = switchhookclk = 64;
11502 136 break;
11503 }
11504 case swRISE:
11505 {
11506 switchhookmaxtime = switchhookclk = 64;
11507 break;
11508 }
11509 }
11510 137 }
11511
11512 46575 bool HeroClass::startwpn(int32_t itemid)
11513 {
11514
1/2
✓ Branch 0 taken 46575 times.
✗ Branch 1 not taken.
46575 if(itemid < 0) return false;
11515 46575 itemdata const& itm = itemsbuf[itemid];
11516
6/6
✓ Branch 0 taken 10783 times.
✓ Branch 1 taken 35792 times.
✓ Branch 2 taken 8680 times.
✓ Branch 3 taken 27112 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 116 times.
46692 if(((dir==up && y<24) || (dir==down && y>world_h-48) ||
11517
6/6
✓ Branch 0 taken 13157 times.
✓ Branch 1 taken 13955 times.
✓ Branch 2 taken 13949 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 46452 times.
46575 (dir==left && x<32) || (dir==right && x>world_w-48)) && !(get_qr(qr_ITEMSONEDGES) || inlikelike))
11518 116 return false;
11519
11520
1/2
✓ Branch 0 taken 46459 times.
✗ Branch 1 not taken.
46459 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
11521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46459 times.
46459 if(liftonly)
11522 {
11523 dowpn = -1;
11524 switch(itm.family)
11525 {
11526 case itype_bomb:
11527 case itype_sbomb:
11528 if(itm.flags & item_flag4)
11529 do_liftglove(-1,false);
11530 break;
11531 case itype_liftglove:
11532 do_liftglove(-1,false);
11533 break;
11534 }
11535 return false;
11536 }
11537
11538 46459 int32_t wx=x;
11539 46459 int32_t wy=y-fakez;
11540 46459 int32_t wz=z;
11541 46459 bool ret = true;
11542
11543
5/5
✓ Branch 0 taken 13915 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 10764 times.
✓ Branch 3 taken 8648 times.
✓ Branch 4 taken 13126 times.
46459 switch(dir)
11544 {
11545 case up:
11546 10764 wy-=16;
11547 10764 break;
11548
11549 case down:
11550 8648 wy+=16;
11551 8648 break;
11552
11553 case left:
11554 13126 wx-=16;
11555 13126 break;
11556
11557 case right:
11558 13915 wx+=16;
11559 13915 break;
11560 }
11561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46459 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46459 if (IsSideSwim() && (itm.flags & item_sideswim_disabled)) return false;
11562
11563
16/26
✗ Branch 0 not taken.
✓ Branch 1 taken 1379 times.
✓ Branch 2 taken 2486 times.
✓ Branch 3 taken 1813 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 369 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 365 times.
✓ Branch 12 taken 1837 times.
✓ Branch 13 taken 20038 times.
✓ Branch 14 taken 1795 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2357 times.
✓ Branch 17 taken 20 times.
✓ Branch 18 taken 13937 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 8 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
46459 switch(itm.family)
11564 {
11565 case itype_liftglove:
11566 {
11567 do_liftglove(itemid,false);
11568 dowpn = -1;
11569 ret = false;
11570 break;
11571 }
11572 case itype_potion:
11573 {
11574
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11575 {
11576 return item_error();
11577 }
11578
11579 35 paymagiccost(itemid);
11580
11581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(itm.misc1 || itm.misc2)
11582 {
11583 35 refill_what=REFILL_ALL;
11584 35 refill_why=itemid;
11585 35 StartRefill(REFILL_ALL);
11586 35 potion_life = game->get_life();
11587 35 potion_magic = game->get_magic();
11588
11589 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11590 //music_pause();
11591 35 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11592
2/2
✓ Branch 0 taken 6288 times.
✓ Branch 1 taken 35 times.
6323 while(refill())
11593 {
11594 6288 do_refill_waitframe();
11595 }
11596
11597 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11598 //music_resume();
11599 35 ret = false;
11600 35 }
11601
11602 35 break;
11603 }
11604 case itype_bottle:
11605 {
11606 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11607 {
11608 return item_error();
11609 }
11610 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11611 return false;
11612
11613 size_t bind = game->get_bottle_slot(itm.misc1);
11614 bool paidmagic = false;
11615 if(itm.script)
11616 {
11617 paidmagic = true;
11618 paymagiccost(itemid);
11619
11620 int i = itemid;
11621 FFCore.reset_script_engine_data(ScriptType::Item, i);
11622 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11623 bind = game->get_bottle_slot(itm.misc1);
11624 }
11625 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11626 if(bt)
11627 {
11628 word toFill[3] = { 0 };
11629 for(size_t q = 0; q < 3; ++q)
11630 {
11631 char c = bt->counter[q];
11632 if(c > -1)
11633 {
11634 if(bt->flags & (1<<q))
11635 {
11636 toFill[q] = (bt->amount[q]==100)
11637 ? game->get_maxcounter(c)
11638 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11639 }
11640 else toFill[q] = bt->amount[q];
11641 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11642 {
11643 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11644 }
11645 }
11646 }
11647 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11648 bool run = max > 0;
11649 bool check_jinxes = true;
11650 if(get_qr(qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11651 {
11652 for(int q = 0; q < 3; ++q)
11653 {
11654 if(bt->counter[q] > -1)
11655 {
11656 check_jinxes = false;
11657 if(!toFill[q])
11658 {
11659 run = false;
11660 break;
11661 }
11662 }
11663 }
11664 }
11665 if(check_jinxes)
11666 {
11667 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11668 run = true;
11669 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11670 run = true;
11671 else if((bt->flags & BTFLAG_CURESHJINX) && shieldjinxclk)
11672 run = true;
11673 }
11674 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11675 {
11676 if(bt->flags & BTFLAG_CURESWJINX)
11677 {
11678 swordclk = 0;
11679 verifyAWpn();
11680 }
11681 if(bt->flags & BTFLAG_CUREITJINX)
11682 itemclk = 0;
11683 if(bt->flags & BTFLAG_CURESHJINX)
11684 shieldjinxclk = 0;
11685 if(!paidmagic)
11686 paymagiccost(itemid);
11687 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11688 sfx(itm.usesound,pan(x.getInt()));
11689 for(size_t q = 0; q < 20; ++q)
11690 do_refill_waitframe();
11691 double inc = max/60.0; //1 second
11692 double xtra[3]{ 0 };
11693 for(size_t q = 0; q < 60; ++q)
11694 {
11695 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11696 sfx(QMisc.miscsfx[sfxREFILL]);
11697 for(size_t j = 0; j < 3; ++j)
11698 {
11699 xtra[j] += inc;
11700 word f = floor(xtra[j]);
11701 xtra[j] -= f;
11702 if(toFill[j] > f)
11703 {
11704 toFill[j] -= f;
11705 game->change_counter(f,bt->counter[j]);
11706 }
11707 else if(toFill[j])
11708 {
11709 game->change_counter(toFill[j],bt->counter[j]);
11710 toFill[j] = 0;
11711 }
11712 }
11713 do_refill_waitframe();
11714 }
11715 for(size_t j = 0; j < 3; ++j)
11716 {
11717 if(toFill[j])
11718 {
11719 game->change_counter(toFill[j],bt->counter[j]);
11720 toFill[j] = 0;
11721 }
11722 }
11723 for(size_t q = 0; q < 20; ++q)
11724 do_refill_waitframe();
11725 game->set_bottle_slot(itm.misc1, bt->next_type);
11726 }
11727 }
11728
11729 dowpn = -1;
11730 ret = false;
11731 break;
11732 }
11733
11734 case itype_note:
11735 {
11736 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11737 {
11738 return item_error();
11739 }
11740 if(!msg_active)
11741 {
11742 if(play_combo_string(itm.misc1, hero_screen))
11743 {
11744 sfx(itm.usesound);
11745 paymagiccost(itemid);
11746 }
11747 }
11748 dowpn = -1;
11749 ret = false;
11750 break;
11751 }
11752
11753 case itype_mirror:
11754 doMirror(itemid);
11755 if(Quit)
11756 return false;
11757 ret = false;
11758 break;
11759
11760 case itype_rocs:
11761 {
11762
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 17 times.
369 if(!do_jump(itemid,false)) return false;
11763 352 ret = false;
11764 }
11765 352 break;
11766
11767 case itype_letter:
11768 {
11769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
8 if(current_item(itype_letter)==i_letter &&
11770
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 (cur_screen >= 128 ? special_warp_return_scr : hero_scr)->room==rP_SHOP &&
11771
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 (cur_screen >= 128 ? special_warp_return_scr : hero_scr)->guy &&
11772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((cur_screen<128&&!(DMaps[cur_dmap].flags&dmfGUYCAVES))
11773
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(cur_screen>=128&&DMaps[cur_dmap].flags&dmfGUYCAVES)) &&
11774 4 checkbunny(itemid)
11775 )
11776 {
11777 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11778
11779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11780 4 getitem(usedid, true, true);
11781
11782
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 sfx((cur_screen >= 128 ? special_warp_return_scr : hero_scr)->secretsfx);
11783 4 setupscreen();
11784 4 action=none; FFCore.setHeroAction(none);
11785 4 }
11786
11787 4 ret = false;
11788 }
11789 4 break;
11790
11791 case itype_whistle:
11792 {
11793 bool whistleflag;
11794
11795
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 365 times.
365 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11796 {
11797 12 return item_error();
11798 }
11799
11800 365 paymagiccost(itemid);
11801 365 sfx(itm.usesound);
11802
11803
4/4
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 143 times.
365 if(dir==up || dir==right)
11804 222 ++blowcnt;
11805 else
11806 143 --blowcnt;
11807
11808 365 uint32_t frames_to_wait = 0;
11809
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 359 times.
365 if (replay_is_active())
11810 {
11811 // How long an sfx takes to play (`sfx_allocated`) is not deterministic,
11812 // use a fixed number of frames in replay mode.
11813 // This has changed over time.
11814
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 142 times.
359 if (replay_version_check(0, 26))
11815 {
11816 217 frames_to_wait = 180;
11817 217 }
11818
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 60 times.
142 else if (replay_version_check(27, 31))
11819 {
11820 82 frames_to_wait = 0;
11821 82 }
11822 else
11823 {
11824 60 SAMPLE* sample = sfx_get_sample(itm.usesound);
11825
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
60 if (sample && sample->freq)
11826 60 frames_to_wait = 60 * sample->len / sample->freq;
11827 }
11828 359 }
11829
11830 365 int sfx_count = 0;
11831
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 49651 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49657 times.
✓ Branch 6 taken 49298 times.
✓ Branch 7 taken 365 times.
49663 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < frames_to_wait))
11832 {
11833 49298 sfx_count += 1;
11834 49298 advanceframe(true);
11835
11836
1/2
✓ Branch 0 taken 49298 times.
✗ Branch 1 not taken.
49298 if(Quit)
11837 return false;
11838 }
11839
11840
9/14
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 359 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 359 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 359 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 359 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 359 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 365 times.
✓ Branch 13 taken 6 times.
365 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11841
11842
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 102 times.
365 if((whistleflag=trigger_secrets_if_flag(x,y,mfWHISTLE,get_qr(qr_PERMANENT_WHISTLE_SECRETS))))
11843 102 didstuff |= did_whistle;
11844
11845
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 259 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
365 if((didstuff&did_whistle && itm.flags&item_flag1) || cur_screen>=128)
11846 106 return false;
11847
11848
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 239 times.
259 if(itm.flags&item_flag1) didstuff |= did_whistle;
11849
11850
4/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 226 times.
259 if((hero_scr->flags&fWHISTLE) || (hero_scr->flags7 & fWHISTLEWATER)
11851
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 || (hero_scr->flags7&fWHISTLEPAL))
11852 {
11853 33 whistleclk=0; // signal to start drying lake or doing other stuff
11854 33 }
11855 else
11856 {
11857 226 int32_t where = itm.misc1;
11858
11859
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 14 times.
226 if(where>right) where=dir^1;
11860
11861
5/6
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 152 times.
378 if(((DMaps[cur_dmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[cur_dmap].flags&dmfWHIRLWINDRET) &&
11862
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
158 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11863 {
11864
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 10 times.
152 zfix windx = where == left ? (zfix)(viewport.right()-16) : where == right ? (zfix)viewport.left() : x;
11865
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 6 times.
152 zfix windy = where == down ? (zfix)viewport.top() : where == up ? zfix(viewport.bottom()-16) : y;
11866
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
304 Lwpns.add(new weapon(
11867
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 windx,
11868
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 windy,
11869
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 (zfix)0,
11870 wWind,
11871 0, //type
11872 0,
11873 152 where,
11874
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11875 152 }
11876
11877 220 whistleitem=itemid;
11878 }
11879
11880 253 ret = false;
11881 }
11882 253 break;
11883
11884 case itype_bomb: case itype_sbomb:
11885 {
11886 1379 bool sbomb = (itm.family == itype_sbomb);
11887 1379 auto lit_ty = sbomb ? wLitSBomb : wLitBomb;
11888 1379 auto boom_ty = sbomb ? wSBomb : wBomb;
11889 //Remote detonation
11890
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1379 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1375 times.
1379 if(Lwpns.idCount(lit_ty) >= zc_max(itm.misc2,1))
11891 {
11892 4 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(lit_ty)));
11893
11894
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 while(Lwpns.idCount(lit_ty) && ew->misc == 0)
11895 {
11896 //If this ever needs a version check, in the future. -z
11897 if (boom_ty == wBomb && (FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31)))
11898 {
11899 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11900 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11901 }
11902 ew->misc=50;
11903 ew->clk=ew->misc-3;
11904 ew->id=boom_ty;
11905 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(lit_ty)));
11906 }
11907
11908 4 deselectbombs(sbomb);
11909 4 return false;
11910 }
11911
11912
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1358 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
1375 if((itm.flags & item_flag4) && lift_wpn)
11913 {
11914 do_liftglove(-1,false); //Throw the already-held weapon
11915 return false;
11916 }
11917
2/4
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1375 times.
1375 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11918 {
11919 return item_error();
11920 }
11921
11922 1375 paymagiccost(itemid);
11923
11924
1/2
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
1375 if(itm.misc1>0) // If not remote bombs
11925 1375 deselectbombs(sbomb);
11926
11927
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 968 times.
1375 if(isdungeon())
11928 {
11929
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 932 times.
968 wy=zc_max(wy,16);
11930 968 }
11931
11932
4/8
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1375 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1375 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1375 times.
✗ Branch 7 not taken.
2750 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,lit_ty,itm.fam_type,
11933
2/4
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1375 times.
✗ Branch 3 not taken.
1375 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
11934 1375 bool lifted = false;
11935
2/2
✓ Branch 0 taken 1358 times.
✓ Branch 1 taken 17 times.
1375 if(itm.flags & item_flag4)
11936 {
11937 17 auto liftid = current_item_id(itype_liftglove);
11938
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 if(liftid > -1 && (itm.weap_data.lift_level <= itemsbuf[liftid].fam_type))
11939 {
11940 17 lift(wpn, itm.weap_data.lift_time, itm.weap_data.lift_height);
11941 17 set_liftflags(liftid);
11942 17 lifted = true;
11943 17 }
11944 17 }
11945
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1358 times.
1375 if(!lifted)
11946 {
11947 1358 Lwpns.add(wpn);
11948 1358 sfx(WAV_PLACE,pan(wx));
11949 1358 }
11950 }
11951 1375 break;
11952
11953 case itype_wand:
11954 {
11955
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 1397 times.
1837 if(Lwpns.idCount(wMagic))
11956 {
11957 440 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11958 440 return false;
11959 }
11960
11961 1397 int32_t bookid = current_item_id(itype_book);
11962
3/4
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 716 times.
1397 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11963
11964
4/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 139 times.
1397 if(!(itm.flags&item_flag1) && !paybook) //Can the wand shoot without the book?
11965 {
11966 139 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11967 139 return false;
11968 }
11969
11970
4/6
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 3 times.
1258 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11971 {
11972 3 return item_error();
11973 }
11974
11975
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 4 times.
1255 if(Lwpns.idCount(wBeam))
11976 4 Lwpns.del(Lwpns.idFirst(wBeam));
11977
11978 int32_t type, pow;
11979
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 722 times.
1255 if ( get_qr(qr_BROKENBOOKCOST) )
11980 {
11981
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 120 times.
533 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11982
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 120 times.
533 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11983 533 }
11984 else
11985 {
11986
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11987
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11988 }
11989
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2510 times.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 1255 times.
2510 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
2510 if(dir!=(i^1))
11991 {
11992
5/10
✓ Branch 0 taken 1255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1255 times.
✗ Branch 9 not taken.
1255 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11993
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
11994 716 magic->linkedItem = bookid;
11995 //magic->dir = this->dir; //Save player dir for special weapons.
11996 1255 Lwpns.add(magic);
11997 1255 }
11998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
1255 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11999 1255 paymagiccost(itemid);
12000 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12001
12002
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12003 716 paymagiccost(current_item_id(itype_book));
12004
12005
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 539 times.
1255 if(bookid != -1)
12006 {
12007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if (( itemsbuf[bookid].flags & item_flag4 ))
12008 {
12009 sfx(itemsbuf[bookid].misc2,pan(wx));
12010 }
12011 else
12012 {
12013 716 sfx(itm.usesound,pan(wx));
12014 }
12015 716 }
12016 else
12017 539 sfx(itm.usesound,pan(wx));
12018 }
12019 /*
12020 // Fireball Wand
12021 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
12022 switch (dir)
12023 {
12024 case up:
12025 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
12026 Lwpns.spr(Lwpns.Count()-1)->dir=up;
12027 break;
12028 case down:
12029 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
12030 Lwpns.spr(Lwpns.Count()-1)->dir=down;
12031 break;
12032 case left:
12033 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
12034 Lwpns.spr(Lwpns.Count()-1)->dir=left;
12035 break;
12036 case right:
12037 Lwpns.spr(Lwpns.Count()-1)->angle=0;
12038 Lwpns.spr(Lwpns.Count()-1)->dir=right;
12039 break;
12040 }
12041 Lwpns.spr(Lwpns.Count()-1)->clk=16;
12042 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
12043 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
12044 */
12045 1255 break;
12046
12047 case itype_sword:
12048 {
12049
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20038 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20038 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
12050 {
12051 return item_error();
12052 }
12053
12054
4/4
✓ Branch 0 taken 4269 times.
✓ Branch 1 taken 15769 times.
✓ Branch 2 taken 4269 times.
✓ Branch 3 taken 15769 times.
20038 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
12055 {
12056 4269 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12057 4269 return false;
12058 }
12059
12060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15769 times.
15769 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
12061 15769 paymagiccost(itemid);
12062 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12063
12064 int temppower;
12065
1/2
✓ Branch 0 taken 15769 times.
✗ Branch 1 not taken.
15769 if(itm.flags & item_flag2)
12066 {
12067 15769 temppower=game->get_hero_dmgmult()*itm.power;
12068 15769 temppower=temppower*itm.misc2;
12069 15769 temppower=temppower/100;
12070 15769 }
12071 else
12072 {
12073 temppower = game->get_hero_dmgmult()*itm.misc2;
12074 }
12075
12076
5/10
✓ Branch 0 taken 15769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15769 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15769 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15769 times.
✗ Branch 9 not taken.
15769 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,temppower,dir,itemid,getUID(),false,false,true));
12077 15769 sfx(itm.usesound2, pan(wx));
12078 }
12079 15769 break;
12080
12081 case itype_candle:
12082 {
12083 1795 int32_t countid = itemid;
12084
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1716 times.
1795 if(get_qr(qr_CANDLES_SHARED_LIMIT))
12085 1716 countid = -itype_candle;
12086
5/6
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 1776 times.
1795 if(itm.flags&item_flag1 && usecounts[countid] >= zc_max(1, itm.misc3))
12087 {
12088 19 return false;
12089 }
12090
12091
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 1680 times.
1776 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
12092 {
12093 96 return false;
12094 }
12095
12096
3/4
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1671 times.
1680 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12097 {
12098 9 return item_error();
12099 }
12100
12101 1671 paymagiccost(itemid);
12102
12103
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 369 times.
1671 if(itm.flags&item_flag1) ++usecounts[countid];
12104
12105
4/8
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1671 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1671 times.
✗ Branch 7 not taken.
3342 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
12106 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12107 1671 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12108
2/4
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
1671 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12109 1671 sfx(itm.usesound,pan(wx));
12110 1671 attack=wFire;
12111 }
12112 1671 break;
12113
12114 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
12115 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
12116 {
12117 int32_t wtype = wScript1 + (itm.family-itype_script1);
12118 if(Lwpns.idCount(wtype))
12119 return false;
12120
12121 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12122 {
12123 return item_error();
12124 }
12125
12126 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12127 paymagiccost(itemid);
12128
12129 zfix wpnstep = zfix(itm.misc1)/100;
12130 if(replay_version_check(0,30))
12131 wpnstep = itm.misc1/100;
12132
12133 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12134 if(!(itm.weap_data.flags & wdata_set_step))
12135 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12136 sfx(itm.usesound,pan(wx));
12137 }
12138 break;
12139
12140 case itype_icerod:
12141 {
12142 if(Lwpns.idCount(wIce))
12143 return false;
12144
12145 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12146 {
12147 return item_error();
12148 }
12149
12150 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12151 paymagiccost(itemid);
12152
12153 zfix wpnstep = zfix(itm.misc1)/100;
12154 if(replay_version_check(0,30))
12155 wpnstep = itm.misc1/100;
12156
12157 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12158 if(!(itm.weap_data.flags & wdata_set_step))
12159 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12160 sfx(itm.usesound,pan(wx));
12161 }
12162 break;
12163
12164 case itype_arrow:
12165 {
12166
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2357 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 2268 times.
2357 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
12167 89 return false;
12168
12169
3/4
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2254 times.
2268 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12170 {
12171 14 return item_error();
12172 }
12173
12174 2254 paymagiccost(itemid);
12175
12176
6/12
✓ Branch 0 taken 2254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2254 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2254 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2254 times.
✗ Branch 11 not taken.
2254 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12177 2254 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
12178 2254 sfx(itm.usesound,pan(wx));
12179 }
12180 2254 break;
12181
12182 case itype_bait:
12183 {
12184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
12185 return false;
12186
12187
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3 times.
20 if(!checkbunny(itemid))
12188 3 return item_error();
12189
12190
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
33 bool grumble = (hero_scr->room==rGRUMBLE && (!getmapflag(hero_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (hero_scr->flags9&fBELOWRETURN)));
12191
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool checkcost = grumble || !(itm.flags & item_flag4);
12192
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool paycost = grumble || !(itm.flags & (item_flag4|item_flag5));
12193
12194
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17 if(!grumble && (itm.flags & item_flag2))
12195 return item_error(); //Only usable for grumble rooms
12196
12197
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
17 if(checkcost && !checkmagiccost(itemid))
12198 return item_error();
12199
12200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(paycost)
12201 17 paymagiccost(itemid);
12202 17 sfx(itm.usesound,pan(wx));
12203
12204
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 if(grumble)
12205 {
12206
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
12207 16 fadeclk=66;
12208 16 dismissmsg();
12209 16 clear_bitmap(pricesdisplaybuf);
12210 16 set_clip_state(pricesdisplaybuf, 1);
12211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 setmapflag(hero_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
12212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itm.flags & item_flag3)) //"Don't remove when feeding" flag
12213 {
12214 16 removeItemsOfFamily(game,itemsbuf,itype_bait);
12215 16 verifyBothWeapons();
12216 16 }
12217 16 sfx(hero_scr->secretsfx);
12218 16 return false;
12219 }
12220
12221
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
12222 1 break;
12223 }
12224
12225 case itype_brang:
12226 {
12227
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13610 times.
13937 if(Lwpns.idCount(wBrang) > itm.misc2)
12228 327 return false;
12229
12230
2/4
✓ Branch 0 taken 13610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13610 times.
13610 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12231 {
12232 return item_error();
12233 }
12234
12235 13610 paymagiccost(itemid);
12236 13610 current_item_power(itype_brang);
12237
6/12
✓ Branch 0 taken 13610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13610 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13610 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13610 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13610 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13610 times.
✗ Branch 11 not taken.
13610 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
12238 }
12239 13610 break;
12240
12241 case itype_hookshot:
12242 case itype_switchhook:
12243 {
12244
3/4
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485 times.
2486 if(inlikelike || Lwpns.idCount(wHookshot))
12245 1 return false;
12246
12247
2/4
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485 times.
2485 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12248 {
12249 return item_error();
12250 }
12251 2485 bool sw = itm.family == itype_switchhook;
12252
12253
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2483 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2485 if(sw && (itm.flags&item_flag8))
12254 switchhook_cost_item = itemid;
12255 2485 else paymagiccost(itemid);
12256
12257 2485 bool use_hookshot=true;
12258 2485 bool hit_hs = false, hit_solid = false, insta_switch = false;
12259
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2384 times.
2485 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
12260 2485 rpos_t rpos = rpos_t::None;
12261 2485 ffcdata* ffc = nullptr;
12262
4/4
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 5772 times.
✓ Branch 2 taken 5738 times.
✓ Branch 3 taken 2485 times.
8223 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
12263 {
12264
2/2
✓ Branch 0 taken 4719 times.
✓ Branch 1 taken 1019 times.
5738 if(dir==up)
12265 {
12266
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 24 times.
1019 if(check_hshot(i,x+2,y-7,sw, &rpos, &ffc))
12267 24 hit_hs = true;
12268 1019 }
12269
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 3673 times.
4719 else if(dir==down)
12270 {
12271
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(check_hshot(i,x+12,y+23,sw, &rpos, &ffc))
12272 hit_hs = true;
12273 1046 }
12274
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 1851 times.
3673 else if(dir==left)
12275 {
12276
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 9 times.
1822 if(check_hshot(i,x-7,y+12,sw, &rpos, &ffc))
12277 9 hit_hs = true;
12278 1822 }
12279
1/2
✓ Branch 0 taken 1851 times.
✗ Branch 1 not taken.
1851 else if(dir==right)
12280 {
12281
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 3 times.
1851 if(check_hshot(i,x+23,y+12,sw, &rpos, &ffc))
12282 3 hit_hs = true;
12283 1851 }
12284 //Diagonal Hookshot (6)
12285 else if(dir==r_down)
12286 {
12287 if(check_hshot(i,x+9,y+13,sw, &rpos, &ffc))
12288 hit_hs = true;
12289 }
12290 else if(dir==l_down)
12291 {
12292 if(check_hshot(i,x+6,y+13,sw, &rpos, &ffc))
12293 hit_hs = true;
12294 }
12295 else if(dir==r_up)
12296 {
12297 if(check_hshot(i,x+9,y+13,sw, &rpos, &ffc))
12298 hit_hs = true;
12299 }
12300 else if(dir==l_up)
12301 {
12302 if(check_hshot(i,x+6,y+13,sw, &rpos, &ffc))
12303 hit_hs = true;
12304 }
12305 5738 }
12306
8/10
✓ Branch 0 taken 2067 times.
✓ Branch 1 taken 418 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 418 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 2456 times.
✓ Branch 9 taken 29 times.
2485 if(dir==up && _walkflag(x+2,y+4,1,STANDING_Z_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
12307 29 hit_solid = true;
12308
2/2
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 36 times.
2485 if(hit_hs)
12309 {
12310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(sw)
12311 insta_switch = true; //switch immediately
12312 36 else use_hookshot = false; //No hooking against grabbable
12313 36 }
12314
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
2485 if(hit_solid && !insta_switch)
12315 29 use_hookshot = false;
12316
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2435 times.
2485 if(use_hookshot)
12317 {
12318 2435 int32_t hookitem = itm.fam_type;
12319 2435 int32_t hookpower = itm.power;
12320 2435 byte allow_diagonal = (itm.flags & item_flag2) ? 1 : 0;
12321
12322
1/2
✓ Branch 0 taken 2435 times.
✗ Branch 1 not taken.
2435 if(!Lwpns.has_space())
12323 {
12324 Lwpns.del(0);
12325 }
12326
12327
1/2
✓ Branch 0 taken 2435 times.
✗ Branch 1 not taken.
2435 if(!Lwpns.has_space(2))
12328 {
12329 Lwpns.del(0);
12330 }
12331
12332
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 440 times.
✓ Branch 3 taken 783 times.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2435 switch(dir)
12333 {
12334 case up:
12335 {
12336 380 hookshot_used=true;
12337 380 hs_switcher = sw;
12338
4/8
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✗ Branch 7 not taken.
760 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12339
2/4
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
380 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12340 380 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12341
5/10
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 380 times.
✗ Branch 9 not taken.
760 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
12342
2/4
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
380 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12343 380 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12344 380 hs_startx=wx;
12345 380 hs_starty=wy-4;
12346 }
12347 380 break;
12348
12349 case down:
12350 {
12351 440 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12352 440 hookshot_used=true;
12353 440 hs_switcher = sw;
12354
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12355
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12356 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12357
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12358
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12359 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12360 440 hs_startx=wx;
12361 440 hs_starty=wy;
12362 }
12363 440 break;
12364
12365 case left:
12366 {
12367 783 hookshot_used=true;
12368 783 hs_switcher = sw;
12369
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12370
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12371 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12372
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12373
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12374 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12375 783 hs_startx=wx-4;
12376 783 hs_starty=wy;
12377 }
12378 783 break;
12379
12380 case right:
12381 {
12382 832 hookshot_used=true;
12383 832 hs_switcher = sw;
12384 // TODO(crash): check that .add succeeds.
12385
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12386
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12387 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12388
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12389
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12390 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12391 832 hs_startx=wx+4;
12392 832 hs_starty=wy;
12393 }
12394 832 break;
12395 //Diagonal Hookshot (7)
12396 case r_down:
12397 {
12398 hookshot_used=true;
12399 hs_switcher = sw;
12400 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12401 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12402 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12403 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12404 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12405 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12406 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12407 hs_startx=wx+4;
12408 hs_starty=wy;
12409 }
12410 break;
12411
12412 case r_up:
12413 {
12414 hookshot_used=true;
12415 hs_switcher = sw;
12416 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12417 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12418 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12419 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12420 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12421 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12422 hs_startx=wx+4;
12423 hs_starty=wy;
12424 }
12425 break;
12426
12427 case l_down:
12428 {
12429 hookshot_used=true;
12430 hs_switcher = sw;
12431 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12432 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12433 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12434 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12435 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12436 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12437 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12438 hs_startx=wx+4;
12439 hs_starty=wy;
12440 }
12441 break;
12442
12443 case l_up:
12444 {
12445 hookshot_used=true;
12446 hs_switcher = sw;
12447 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12448 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12449 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12450 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12451 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12452 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
12453 hs_startx=wx+4;
12454 hs_starty=wy;
12455 }
12456 break;
12457 }
12458 2435 hookshot_frozen=true;
12459 2435 }
12460
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if(insta_switch)
12461 {
12462 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
12463 if (rpos != rpos_t::None) hooked_comborpos = rpos;
12464 if (ffc)
12465 {
12466 ffc->switch_hooked = true;
12467 switching_object = ffc;
12468 }
12469 w->misc=2;
12470 w->step=0;
12471 doSwitchHook(itm.misc5);
12472 if(itm.usesound2)
12473 sfx(itm.usesound2,pan(int32_t(x)));
12474 else if(QMisc.miscsfx[sfxSWITCHED])
12475 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
12476 stop_sfx(itm.usesound);
12477 }
12478 }
12479 2485 break;
12480
12481 case itype_divinefire:
12482
3/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12483 return false;
12484
12485
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12486 {
12487 return item_error();
12488 }
12489
12490 12 paymagiccost(itemid);
12491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12492 12 else {action=casting; FFCore.setHeroAction(casting);}
12493 12 magicitem=itemid;
12494 12 break;
12495
12496 case itype_divineescape:
12497
3/12
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12498 return false;
12499
12500
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12501 {
12502 return item_error();
12503 }
12504
12505 8 paymagiccost(itemid);
12506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12507 8 else {action=casting; FFCore.setHeroAction(casting);}
12508 8 magicitem=itemid;
12509 8 break;
12510
12511 case itype_divineprotection:
12512 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12513 return false;
12514
12515 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12516 {
12517 return item_error();
12518 }
12519
12520 paymagiccost(itemid);
12521 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12522 else {action=casting; FFCore.setHeroAction(casting);}
12523 magicitem=itemid;
12524 break;
12525
12526 case itype_cbyrna:
12527 {
12528 //Beams already deployed
12529
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
12530 {
12531 2 stopCaneOfByrna();
12532 2 return false;
12533 }
12534
12535
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12536 {
12537 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
12538 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
12539 return false;
12540 }
12541
12542 2 paymagiccost(itemid);
12543 2 last_cane_of_byrna_item_id = itemid;
12544
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
12545 {
12546 //byrna weapons are added here
12547 //space them apart
12548 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
12549 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
12550
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12551 2 }
12552
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
12553 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
12554 }
12555 2 break;
12556
12557 case itype_clock:
12558 {
12559 ret = false;
12560 if(!(itm.flags & item_flag1))
12561 break; //Passive clock, don't use
12562 if((itm.flags & item_flag2) && watch) //"Can't activate while clock active"
12563 break;
12564 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
12565 {
12566 return item_error();
12567 }
12568
12569 paymagiccost(itemid);
12570
12571 setClock(watch=true);
12572
12573 clock_zoras.clear();
12574
12575 clockclk=itm.misc1;
12576 sfx(itm.usesound);
12577 break;
12578 }
12579 case itype_killem:
12580 {
12581 ret = false;
12582 if(!(itm.flags & item_flag1))
12583 break; //Passive killemall, don't use
12584
12585 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12586 || !can_kill_em_all()) //No enemies onscreen
12587 {
12588 return item_error();
12589 }
12590
12591 paymagiccost(itemid);
12592
12593 kill_em_all();
12594 sfx(itm.usesound);
12595 break;
12596 }
12597 case itype_refill:
12598 {
12599 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12600 {
12601 return item_error();
12602 }
12603
12604 bool did_something = false;
12605
12606 if(itm.flags & item_flag1) //Cure sword jinx
12607 {
12608 if(swordclk)
12609 did_something = true;
12610 swordclk = 0;
12611 verifyAWpn();
12612 }
12613 for(auto q = 0; q < 5; ++q)
12614 {
12615 auto ctr = itm.misc(q);
12616 if(unsigned(ctr) >= MAX_COUNTERS)
12617 continue;
12618 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12619 if(!amnt) continue;
12620 bool gradual = itm.flags & item_flag2;
12621 if(amnt > 0)
12622 {
12623 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12624 {
12625 //Can't *do* anything... skip
12626 continue;
12627 }
12628 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12629 {
12630 //Can't do anything unless affecting dcounter
12631 gradual = true;
12632 }
12633 }
12634 else //Negative
12635 {
12636 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12637 {
12638 //Can't *do* anything... skip
12639 continue;
12640 }
12641 if(game->get_counter(ctr) <= 0)
12642 {
12643 //Can't do anything unless affecting dcounter
12644 gradual = true;
12645 }
12646 }
12647 did_something = true;
12648 if(gradual) //Gradual
12649 {
12650 game->change_dcounter(amnt, ctr);
12651 }
12652 else
12653 {
12654 game->change_counter(amnt, ctr);
12655 }
12656 }
12657 if(!did_something)
12658 {
12659 return item_error();
12660 }
12661 paymagiccost(itemid);
12662 sfx(itm.usesound);
12663 ret = false;
12664 break;
12665 }
12666
12667 default:
12668 1813 ret = false;
12669 1813 }
12670
12671
2/2
✓ Branch 0 taken 40864 times.
✓ Branch 1 taken 35 times.
40899 if(itm.flags & item_downgrade)
12672 {
12673 35 game->set_item(itemid,false);
12674
12675 // Maybe Item Override has allowed the same item in both slots?
12676
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Bwpn == itemid)
12677 {
12678 Bwpn = -1;
12679 game->forced_bwpn = -1;
12680 verifyBWpn();
12681 }
12682
12683
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Awpn == itemid)
12684 {
12685 Awpn = -1;
12686 game->forced_awpn = -1;
12687 verifyAWpn();
12688 }
12689
12690
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Xwpn == itemid)
12691 {
12692 Xwpn = -1;
12693 game->forced_xwpn = -1;
12694 verifyXWpn();
12695 }
12696
12697
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Ywpn == itemid)
12698 {
12699 Ywpn = -1;
12700 game->forced_ywpn = -1;
12701 verifyYWpn();
12702 }
12703 35 }
12704
12705 40899 return ret;
12706 46581 }
12707
12708
12709 1866001 bool HeroClass::doattack()
12710 {
12711
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1865984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1866001 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12712 17 return false;
12713 //int32_t s = BSZ ? 0 : 11;
12714 1865984 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12715
12716
4/4
✓ Branch 0 taken 475791 times.
✓ Branch 1 taken 1390193 times.
✓ Branch 2 taken 475647 times.
✓ Branch 3 taken 144 times.
1865984 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12717
3/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1865840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
1865984 if(attack==wBugNet && bugnetid!=-1)
12718 {
12719
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 138 times.
144 if(++attackclk >= NET_CLK_TOTAL)
12720 6 return false;
12721
12722 138 return true;
12723 }
12724
12725 // Abort attack if attackclk has run out and:
12726 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12727 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12728
12729
6/6
✓ Branch 0 taken 183383 times.
✓ Branch 1 taken 1682457 times.
✓ Branch 2 taken 147865 times.
✓ Branch 3 taken 35518 times.
✓ Branch 4 taken 51479 times.
✓ Branch 5 taken 17820 times.
1935139 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12730
12/12
✓ Branch 0 taken 135414 times.
✓ Branch 1 taken 12451 times.
✓ Branch 2 taken 66239 times.
✓ Branch 3 taken 69175 times.
✓ Branch 4 taken 79830 times.
✓ Branch 5 taken 68035 times.
✓ Branch 6 taken 78566 times.
✓ Branch 7 taken 1264 times.
✓ Branch 8 taken 66199 times.
✓ Branch 9 taken 3100 times.
✓ Branch 10 taken 50945 times.
✓ Branch 11 taken 15254 times.
147865 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12731 {
12732 96386 tapping=false;
12733 96386 return false;
12734 }
12735
12736
2/2
✓ Branch 0 taken 2297 times.
✓ Branch 1 taken 1767157 times.
1769454 if(attackclk>29)
12737 {
12738 2297 tapping=false;
12739 2297 return false;
12740 }
12741
12742
4/4
✓ Branch 0 taken 457820 times.
✓ Branch 1 taken 1309337 times.
✓ Branch 2 taken 434838 times.
✓ Branch 3 taken 22982 times.
1767157 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12743
4/4
✓ Branch 0 taken 457820 times.
✓ Branch 1 taken 1309337 times.
✓ Branch 2 taken 457790 times.
✓ Branch 3 taken 30 times.
1767157 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12744 // An attack can be "walked out-of" after 8 frames, unless it's:
12745 // * a sword stab
12746 // * a hammer pound
12747 // * a wand thrust
12748 // * a candle thrust
12749 // * a cane thrust
12750 // In which case it should continue.
12751
8/8
✓ Branch 0 taken 68903 times.
✓ Branch 1 taken 1698254 times.
✓ Branch 2 taken 197612 times.
✓ Branch 3 taken 128709 times.
✓ Branch 4 taken 1623406 times.
✓ Branch 5 taken 203557 times.
✓ Branch 6 taken 361124 times.
✓ Branch 7 taken 1262282 times.
2063171 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12752
5/6
✓ Branch 0 taken 296702 times.
✓ Branch 1 taken 64422 times.
✓ Branch 2 taken 22001 times.
✓ Branch 3 taken 274701 times.
✓ Branch 4 taken 22001 times.
✗ Branch 5 not taken.
361124 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12753
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 274671 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
296702 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12754
2/2
✓ Branch 0 taken 296014 times.
✓ Branch 1 taken 21343 times.
274701 && (attack != wBugNet) && attackclk>7))
12755 {
12756
8/8
✓ Branch 0 taken 93657 times.
✓ Branch 1 taken 4745 times.
✓ Branch 2 taken 89110 times.
✓ Branch 3 taken 4547 times.
✓ Branch 4 taken 83924 times.
✓ Branch 5 taken 5186 times.
✓ Branch 6 taken 5631 times.
✓ Branch 7 taken 78293 times.
493626 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12757 {
12758 20109 lstep = s;
12759 20109 return false;
12760 }
12761 78293 }
12762
12763
2/2
✓ Branch 0 taken 40923 times.
✓ Branch 1 taken 1611005 times.
1651928 if(charging==0)
12764 {
12765 1611005 lstep=0;
12766 1611005 }
12767
12768 // Work out the sword charge-up delay
12769 1651928 int32_t magiccharge = 192, normalcharge = 64;
12770 1651928 int32_t itemid = current_item_id(itype_chargering);
12771
12772
2/2
✓ Branch 0 taken 1600732 times.
✓ Branch 1 taken 51196 times.
1651928 if(itemid>=0)
12773 {
12774
1/2
✓ Branch 0 taken 51196 times.
✗ Branch 1 not taken.
51196 normalcharge = (itemsbuf[itemid].misc1>0)?itemsbuf[itemid].misc1:64;
12775
1/2
✓ Branch 0 taken 51196 times.
✗ Branch 1 not taken.
51196 magiccharge = (itemsbuf[itemid].misc2>normalcharge)?itemsbuf[itemid].misc2:192;
12776 51196 }
12777
12778 1651928 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12779 1651928 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12780
12781 1651928 bool doCharge=true;
12782
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1651778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
1651928 if(z!=0 && fakez != 0)
12783 doCharge=false;
12784
2/2
✓ Branch 0 taken 1262282 times.
✓ Branch 1 taken 389646 times.
1651928 if(attack==wSword)
12785 {
12786
4/4
✓ Branch 0 taken 34916 times.
✓ Branch 1 taken 1227366 times.
✓ Branch 2 taken 613 times.
✓ Branch 3 taken 34303 times.
1262282 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12787 1227979 doCharge=false;
12788
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 23483 times.
34303 else if(charging<=normalcharge)
12789 {
12790
3/6
✓ Branch 0 taken 23483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23483 times.
✗ Branch 5 not taken.
23483 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12791 doCharge=false;
12792 23483 }
12793 1262282 }
12794
2/2
✓ Branch 0 taken 64422 times.
✓ Branch 1 taken 325224 times.
389646 else if(attack==wHammer)
12795 {
12796
4/4
✓ Branch 0 taken 2188 times.
✓ Branch 1 taken 62234 times.
✓ Branch 2 taken 1945 times.
✓ Branch 3 taken 243 times.
64422 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12797 64179 doCharge=false;
12798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 else if(charging<=normalcharge)
12799 {
12800
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
243 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12801 227 doCharge=false;
12802 243 }
12803 64422 }
12804 else
12805 325224 doCharge=false;
12806
12807 // charging up weapon...
12808
2/2
✓ Branch 0 taken 34319 times.
✓ Branch 1 taken 1617609 times.
1651928 if(doCharge)
12809 {
12810 // Increase charging while holding down button.
12811
3/4
✓ Branch 0 taken 34319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2543 times.
✓ Branch 3 taken 31776 times.
34319 if(spins==0 && charging<magiccharge)
12812 31776 charging++;
12813
12814 // Once a charging threshold is reached, play the sound.
12815
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 34145 times.
34319 if(charging==normalcharge)
12816 {
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!(itemsbuf[scrollid].flags&item_flag1))
12818 174 paymagiccost(scrollid);
12819 174 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12820 174 }
12821
2/2
✓ Branch 0 taken 31708 times.
✓ Branch 1 taken 2437 times.
34145 else if(charging==magiccharge)
12822 {
12823
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2434 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
2437 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12824 {
12825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&item_flag1))
12826 3 paymagiccost(scroll2id);
12827 3 charging++; // charging>magiccharge signifies a successful supercharge.
12828 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12829 3 }
12830 2437 }
12831 34319 }
12832
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1617579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
1617609 else if(attack==wCByrna && byrnaid!=-1)
12833 {
12834
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12835 {
12836 attack = wNone;
12837 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12838 }
12839
12840 30 bool beamcount = false;
12841
12842
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12843 {
12844 55 weapon *w = ((weapon*)Lwpns.spr(i));
12845
12846
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12847 {
12848 4 beamcount = true;
12849 4 break;
12850 }
12851 51 }
12852
12853 // If beams already deployed, remove them
12854
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12855 {
12856 2 return startwpn(attackid); // Remove beams instantly
12857 }
12858
12859 // Otherwise, continue
12860 28 ++attackclk;
12861 28 }
12862 else
12863 {
12864 1617579 ++attackclk;
12865
12866
6/6
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 1613531 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 3263 times.
✓ Branch 4 taken 485 times.
✓ Branch 5 taken 300 times.
1617579 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12867 {
12868 300 ++attackclk; // Won't continue charging
12869 300 charging=0;
12870 300 }
12871
12872 // Faster if spinning.
12873
2/2
✓ Branch 0 taken 1614901 times.
✓ Branch 1 taken 2678 times.
1617579 if(spins>0)
12874 2678 ++attackclk;
12875
12876 // Even faster if hurricane spinning.
12877
2/2
✓ Branch 0 taken 1617147 times.
✓ Branch 1 taken 432 times.
1617579 if(spins>5)
12878 432 attackclk+=2;
12879
12880 // If at a charging threshold, do a charged attack.
12881
5/6
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 1615247 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2217 times.
✓ Branch 5 taken 115 times.
1617579 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12882 {
12883
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(attack==wSword)
12884 {
12885
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 bool super = charging>magiccharge && scroll2id > -1;
12886
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112 times.
115 int id = super ? scroll2id : scrollid;
12887 115 itemdata const& spinscroll = itemsbuf[id];
12888 115 bool paid = !(spinscroll.flags&item_flag1);
12889
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(!paid && checkbunny(id) && checkmagiccost(id))
12890 {
12891 paid = true;
12892 paymagiccost(id);
12893 }
12894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(paid)
12895 {
12896 115 currentscroll = id;
12897 115 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12898 115 attackclk=1;
12899
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 114 times.
115 if(!get_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS))
12900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 if(weapon* w = find_first_wtype(wSword))
12901 1 w->reset_wgrids();
12902 115 sfx(spinscroll.usesound,pan(x.getInt()));
12903
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(spinscroll.flags&item_flag1)
12904 paymagiccost(id);
12905 115 }
12906 115 }
12907 else if(attack==wHammer && sideviewhammerpound())
12908 {
12909 bool super = charging>magiccharge && scroll2id > -1;
12910 int id = super ? scroll2id : scrollid;
12911 itemdata const& quakescroll = itemsbuf[id];
12912 bool paid = !(quakescroll.flags&item_flag1);
12913 if(!paid && checkbunny(id) && checkmagiccost(id))
12914 {
12915 paid = true;
12916 paymagiccost(id);
12917 }
12918 if(paid)
12919 {
12920 currentscroll = id;
12921 spins = super ? 2 : 1;
12922 sfx(quakescroll.usesound,pan(x.getInt()));
12923 quakeclk=quakescroll.misc1;
12924
12925 // general area stun
12926 for(int32_t i=0; i<GuyCount(); i++)
12927 {
12928 if(!isflier(GuyID(i)))
12929 {
12930 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12931 }
12932 }
12933
12934 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12935 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12936 if(hmrlvl < 1) hmrlvl = 1;
12937 int rad = quakescroll.misc2;
12938 for_every_combo([&](const auto& handle) {
12939 auto [cx, cy] = handle.xy();
12940 if (distance(x, y, cx, cy) > rad)
12941 return;
12942
12943 vector<int> trigflags = {TRIGFLAG_QUAKESTUN};
12944 if(super) trigflags.push_back(TRIGFLAG_SQUAKESTUN);
12945 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
12946 if(!trig.trigger_flags.any(trigflags)) return false;
12947 return (trig.trigger_flags.get(TRIGFLAG_INVERTMINMAX)
12948 ? hmrlvl <= trig.triggerlevel : hmrlvl >= trig.triggerlevel);
12949 });
12950 });
12951 }
12952 }
12953 115 }
12954
6/6
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 1613393 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 347 times.
✓ Branch 5 taken 3239 times.
1617464 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12955 3239 charging++;
12956
12957
7/8
✓ Branch 0 taken 21601 times.
✓ Branch 1 taken 1595978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1595978 times.
✓ Branch 4 taken 25736 times.
✓ Branch 5 taken 1570242 times.
✓ Branch 6 taken 907657 times.
✓ Branch 7 taken 709922 times.
1617579 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12958 709922 charging=0;
12959
12960
2/2
✓ Branch 0 taken 1589791 times.
✓ Branch 1 taken 27788 times.
1617579 if(attackclk>=SWORDCHARGEFRAME)
12961 27788 tapping = false;
12962 }
12963
12964
7/8
✓ Branch 0 taken 125960 times.
✓ Branch 1 taken 1525966 times.
✓ Branch 2 taken 1805 times.
✓ Branch 3 taken 124155 times.
✓ Branch 4 taken 1805 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1758 times.
1651926 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12965 {
12966 1758 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12967 }
12968
12969 1650168 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12970
12971
11/14
✓ Branch 0 taken 1549846 times.
✓ Branch 1 taken 100322 times.
✓ Branch 2 taken 114498 times.
✓ Branch 3 taken 1435348 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 114048 times.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 438 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
1650168 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12972 {
12973
12974
4/4
✓ Branch 0 taken 18502 times.
✓ Branch 1 taken 81832 times.
✓ Branch 2 taken 14966 times.
✓ Branch 3 taken 3536 times.
100334 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12975
2/2
✓ Branch 0 taken 99931 times.
✓ Branch 1 taken 403 times.
100334 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12976
12977
4/4
✓ Branch 0 taken 99931 times.
✓ Branch 1 taken 403 times.
✓ Branch 2 taken 27091 times.
✓ Branch 3 taken 72840 times.
100334 if(wpnid>=0 && itemsbuf[wpnid].flags & item_flag1)
12978 {
12979 72840 templife=templife*game->get_maxlife();
12980 72840 templife=templife/100;
12981 72840 }
12982 else
12983 {
12984 27494 templife*=game->get_hp_per_heart();
12985 }
12986
12987
2/2
✓ Branch 0 taken 37146 times.
✓ Branch 1 taken 63188 times.
100334 bool normalbeam = (int64_t(game->get_life())+(get_qr(qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12988 100334 int32_t perilid = current_item_id(itype_perilscroll);
12989
3/4
✓ Branch 0 taken 7511 times.
✓ Branch 1 taken 92823 times.
✓ Branch 2 taken 7511 times.
✗ Branch 3 not taken.
100405 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12990
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 7440 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
7511 && checkbunny(perilid) && checkmagiccost(perilid)
12991 // Must actually be able to shoot sword beams
12992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 && ((itemsbuf[wpnid].flags & item_flag1)
12993
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 70 times.
71 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12994
12995
4/4
✓ Branch 0 taken 85190 times.
✓ Branch 1 taken 15144 times.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 84659 times.
100334 if(attack==wSword && !tapping)
12996 {
12997
4/4
✓ Branch 0 taken 84590 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 20024 times.
✓ Branch 3 taken 64566 times.
84659 if(perilbeam || normalbeam)
12998 {
12999
1/2
✓ Branch 0 taken 20093 times.
✗ Branch 1 not taken.
20093 if(attackclk==7)
13000 paymagiccost(crossid); // Pay the Cross Beams magic cost.
13001
13002
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 20024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
20093 if(perilbeam && !normalbeam)
13003 69 paymagiccost(perilid); // Pay the Peril Beam magic cost.
13004
13005 // TODO: Something that would be cheap but disgraceful to hack in at this point is
13006 // a way to make the peril/cross beam item's power stat influence the strength
13007 // of the peril/cross beam...
13008 20093 startwpn(attackid);
13009 20093 }
13010 64566 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
13011 84659 }
13012
13013
2/2
✓ Branch 0 taken 98497 times.
✓ Branch 1 taken 1837 times.
100334 if(attack==wWand)
13014 1837 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
13015
13016
5/6
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 99028 times.
✓ Branch 2 taken 1306 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1259 times.
✓ Branch 5 taken 47 times.
100334 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
13017 47 startwpn(attackid);
13018
13019
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 100332 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
100334 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
13020 2 startwpn(attackid);
13021 100334 }
13022
13023
2/2
✓ Branch 0 taken 1550729 times.
✓ Branch 1 taken 99439 times.
1650168 if(attackclk==14)
13024 99439 lstep = s;
13025
13026 1650168 return true;
13027 1770881 }
13028
13029 27148958 bool HeroClass::can_attack()
13030 {
13031
4/4
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 27138138 times.
✓ Branch 2 taken 2880 times.
✓ Branch 3 taken 7940 times.
27148958 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
13032 7940 return false;
13033
4/4
✓ Branch 0 taken 26816640 times.
✓ Branch 1 taken 324378 times.
✓ Branch 2 taken 18162250 times.
✓ Branch 3 taken 8654390 times.
27141018 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13034
4/6
✓ Branch 0 taken 27141018 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26873924 times.
✓ Branch 3 taken 267094 times.
✓ Branch 4 taken 26873924 times.
✗ Branch 5 not taken.
28547258 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
13035
5/8
✓ Branch 0 taken 26873924 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26873924 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26873924 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26867016 times.
✓ Branch 7 taken 6908 times.
26873924 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
13036
3/4
✓ Branch 0 taken 26867016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23526859 times.
✓ Branch 3 taken 3340157 times.
26867016 || ((action==attacking||action==sideswimattacking)
13037
2/2
✓ Branch 0 taken 742134 times.
✓ Branch 1 taken 26124882 times.
26867016 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & item_flag5))
13038
2/2
✓ Branch 0 taken 26788988 times.
✓ Branch 1 taken 664106 times.
26867016 && charging!=0))
13039 {
13040 1680242 return false;
13041 }
13042
13043 26788988 int32_t r = (isdungeon()) ? 16 : 0;
13044 26788988 int32_t r2 = get_qr(qr_NOBORDER) ? 0 : 8;
13045
13046
4/5
✓ Branch 0 taken 7557874 times.
✓ Branch 1 taken 19231114 times.
✓ Branch 2 taken 8488934 times.
✓ Branch 3 taken 10742180 times.
✗ Branch 4 not taken.
26788988 if(!get_qr(qr_ITEMSONEDGES)) switch(dir)
13047 {
13048 case up:
13049 case down:
13050
2/2
✓ Branch 0 taken 8188910 times.
✓ Branch 1 taken 300024 times.
8488934 return !(y<(r2+r) || y>(world_h-16-r-r2));
13051
13052 case left:
13053 case right:
13054
2/2
✓ Branch 0 taken 10453168 times.
✓ Branch 1 taken 289012 times.
10742180 return !(x<(r2+r) || x>(world_w-16-r-r2));
13055 }
13056
13057 7557874 return true;
13058 28477170 }
13059
13060 16775 bool isRaftFlag(int32_t flag)
13061 {
13062
4/4
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 7984 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 8536 times.
16775 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
13063 }
13064
13065 7642155 void handle_lens_triggers(int32_t l_id)
13066 {
13067
2/2
✓ Branch 0 taken 7635872 times.
✓ Branch 1 taken 6283 times.
7642155 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & item_flag6);
13068 7642155 auto& combo_cache = combo_caches::lens;
13069 3133840298 for_every_combo([&](const auto& handle) {
13070 3126198143 auto cid = handle.data();
13071 3126198143 auto& mini_cmb = combo_cache.minis[cid];
13072
7/8
✓ Branch 0 taken 120384 times.
✓ Branch 1 taken 3123581824 times.
✓ Branch 2 taken 3123702022 times.
✓ Branch 3 taken 186 times.
✓ Branch 4 taken 1596 times.
✓ Branch 5 taken 2494339 times.
✓ Branch 6 taken 2495935 times.
✗ Branch 7 not taken.
3126198143 if (!(enabled ? mini_cmb.on : mini_cmb.off))
13073 3126197957 return;
13074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
372 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
13075 186 return trig.trigger_flags.get(enabled ? TRIGFLAG_LENSON : TRIGFLAG_LENSOFF);
13076 });
13077 3126198143 });
13078 7642155 }
13079
13080 13705680 void do_lens()
13081 {
13082
2/2
✓ Branch 0 taken 6063525 times.
✓ Branch 1 taken 7642155 times.
13705680 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
13083 {
13084 6063525 do_210_lens();
13085 6063525 return;
13086 }
13087
13088 7642155 int32_t wpnPressed = getWpnPressed(itype_lens);
13089
6/6
✓ Branch 0 taken 6280 times.
✓ Branch 1 taken 7635875 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 7635499 times.
✓ Branch 4 taken 391205 times.
✓ Branch 5 taken 7244294 times.
7642155 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
13090
2/2
✓ Branch 0 taken 6085159 times.
✓ Branch 1 taken 1556996 times.
7642155 if(itemid >= 0)
13091 {
13092
8/10
✓ Branch 0 taken 5364 times.
✓ Branch 1 taken 1551632 times.
✓ Branch 2 taken 5364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✓ Branch 5 taken 4669 times.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 529 times.
1556996 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
13093 {
13094
2/2
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 210 times.
529 if(lensid<0)
13095 {
13096 210 lensid=itemid;
13097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(itemsbuf[itemid].family == itype_lens)
13098 210 Hero.setLastLensID(itemid);
13099
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 13 times.
210 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13100 210 }
13101
13102 529 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
13103
13104
2/10
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 529 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
529 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13105 {
13106 //clear the item script stack for a new script
13107 int i = itemid;
13108 FFCore.reset_script_engine_data(ScriptType::Item, i);
13109 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13110 did_scriptl=true;
13111 }
13112
13113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13114 529 else lensclk = 12;
13115 529 }
13116 else
13117 {
13118 1556467 did_scriptl=false;
13119
2/2
✓ Branch 0 taken 1550713 times.
✓ Branch 1 taken 5754 times.
1556467 if(!lensclk)
13120 {
13121
13122
2/2
✓ Branch 0 taken 1550506 times.
✓ Branch 1 taken 207 times.
1550713 if(lensid>-1)
13123 {
13124 207 lensid=-1;
13125 207 lensclk = 0;
13126
13127
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 12 times.
207 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13128 207 }
13129 1550713 }
13130 }
13131 1556996 }
13132 7642155 handle_lens_triggers(lensid);
13133 13705680 }
13134
13135 6063525 void do_210_lens()
13136 {
13137 6063525 int32_t wpnPressed = getWpnPressed(itype_lens);
13138
4/4
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 6060191 times.
✓ Branch 2 taken 487 times.
✓ Branch 3 taken 6059704 times.
6063525 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>-1 ? wpnPressed : current_item_id(itype_lens);
13139
2/2
✓ Branch 0 taken 1226986 times.
✓ Branch 1 taken 4836539 times.
6063525 if(itemid<0)
13140 4836539 return;
13141
13142
7/8
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 1223643 times.
✓ Branch 2 taken 3343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 2821 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 515 times.
1226986 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
13143 {
13144
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 480 times.
515 if(lensid<0)
13145 {
13146 480 lensid=itemid;
13147
13148
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13149 480 }
13150
13151 515 paymagiccost(itemid, true);
13152
13153
2/10
✓ Branch 0 taken 515 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 515 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
515 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13154 {
13155 //clear the item script stack for a new script
13156 int i = itemid;
13157 FFCore.reset_script_engine_data(ScriptType::Item, i);
13158 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13159 did_scriptl=true;
13160 }
13161
13162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
515 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13163 515 else lensclk = 12;
13164 515 }
13165 else
13166 {
13167 1226471 did_scriptl=false;
13168
13169
7/8
✓ Branch 0 taken 3299 times.
✓ Branch 1 taken 1223172 times.
✓ Branch 2 taken 2821 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 2821 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2820 times.
✓ Branch 7 taken 1 times.
1226471 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
13170 {
13171 479 lensid=-1;
13172 479 lensclk = 0;
13173
13174
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13175 479 }
13176 }
13177 6063525 }
13178
13179 14081 void HeroClass::do_hopping()
13180 {
13181 14081 do_lens();
13182
13183
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 13527 times.
14081 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
13184 //Possible fix for exiting water in diagonal movement. -Z
13185 {
13186 554 int32_t flippers_id = current_item_id(itype_flippers);
13187
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 550 times.
554 if(diveclk>0)
13188 {
13189 4 --diveclk;
13190
2/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && DrunkrAbtn()) //Cancellable Diving -V
13191 {
13192 diveclk = itemsbuf[flippers_id].misc2;
13193 }
13194 4 }
13195
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 2 times.
550 else if(DrunkrAbtn())
13196 {
13197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
13198 2 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
13199
13200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(global_diving==screen_diving)
13201
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13202 2 }
13203
13204
6/8
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 398 times.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 156 times.
554 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
13205 {
13206 398 SetSwim();
13207 398 hopclk = 0;
13208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!IsSideSwim())
13209 {
13210 398 charging = attackclk = 0;
13211 398 tapping = false;
13212 398 }
13213 398 }
13214 else
13215 {
13216 156 herostep();
13217
13218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if(!isDiving() || (frame&1))
13219 {
13220
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 77 times.
156 switch(dir)
13221 {
13222 case up:
13223 42 y -= 1;
13224 42 break;
13225
13226 case down:
13227 7 y += 1;
13228 7 break;
13229
13230 case left:
13231 30 x -= 1;
13232 30 break;
13233
13234 case right:
13235 77 x += 1;
13236 77 break;
13237 }
13238 156 }
13239 }
13240 554 }
13241 else // hopping in or out (need to separate the cases...)
13242 {
13243
4/6
✓ Branch 0 taken 12509 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 12509 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12509 times.
13527 if((diagonalMovement||NO_GRIDLOCK))
13244 {
13245
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 375 times.
1018 if(hopclk==1) //hopping out
13246 //>= 1 possible fix for getting stuck on land edges.
13247 //No, this is not a clock. it's a type. 1 == out, 2 == in.
13248 {
13249
1/2
✓ Branch 0 taken 375 times.
✗ Branch 1 not taken.
375 if(hopdir!=-1) dir=hopdir;
13250
13251 375 landswim=0;
13252
13253
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 101 times.
375 if(dir==up)
13254 {
13255 101 herostep();
13256 101 herostep();
13257 101 int32_t sidestep=0;
13258
13259
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101 times.
101 if(iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13260 sidestep=1;
13261
3/6
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101 times.
✗ Branch 5 not taken.
101 else if(!iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13262 sidestep=2;
13263
13264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(sidestep==1) x++;
13265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 else if(sidestep==2) x--;
13266 101 else y--;
13267
13268
3/4
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 8 times.
101 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13269 {
13270 8 hopclk=0;
13271 8 diveclk=0;
13272 8 action=none; FFCore.setHeroAction(none);
13273 8 hopdir=-1;
13274 8 }
13275 101 }
13276
13277
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 72 times.
375 if(dir==down)
13278 {
13279 72 herostep();
13280 72 herostep();
13281 72 int32_t sidestep=0;
13282
13283
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if(iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13284 sidestep=1;
13285
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
72 else if(!iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13286 sidestep=2;
13287
13288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(sidestep==1) x++;
13289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 else if(sidestep==2) x--;
13290 72 else y++;
13291
13292
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
72 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13293 {
13294 6 hopclk=0;
13295 6 diveclk=0;
13296 6 action=none; FFCore.setHeroAction(none);
13297 6 hopdir=-1;
13298 6 }
13299 72 }
13300
13301
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 57 times.
375 if(dir==left)
13302 {
13303 57 herostep();
13304 57 herostep();
13305 57 int32_t sidestep=0;
13306
13307
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
57 if(iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?8:12)), -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13308 sidestep=1;
13309
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 else if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?7:11)), -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13310 sidestep=2;
13311
13312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(sidestep==1) y++;
13313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 else if(sidestep==2) y--;
13314 57 else x--;
13315
13316
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 4 times.
57 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13317 {
13318 4 hopclk=0;
13319 4 diveclk=0;
13320 4 action=none; FFCore.setHeroAction(none);
13321 4 hopdir=-1;
13322 4 }
13323 57 }
13324
13325
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 145 times.
375 if(dir==right)
13326 {
13327 145 herostep();
13328 145 herostep();
13329 145 int32_t sidestep=0;
13330
13331
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 145 times.
145 if(iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?8:12)), -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13332 sidestep=1;
13333
3/6
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
145 else if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?7:11)), -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13334 sidestep=2;
13335
13336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(sidestep==1) y++;
13337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 else if(sidestep==2) y--;
13338 145 else x++;
13339
13340
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
145 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13341 {
13342 11 hopclk=0;
13343 11 diveclk=0;
13344 11 action=none; FFCore.setHeroAction(none);
13345 11 hopdir=-1;
13346 11 }
13347 145 }
13348 375 }
13349
13350
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 643 times.
1018 if(hopclk==2) //hopping in
13351 {
13352 643 landswim=0;
13353
13354
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 89 times.
643 if(dir==up)
13355 {
13356 89 herostep();
13357 89 herostep();
13358 89 int32_t sidestep=0;
13359
13360
6/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 88 times.
89 if(!iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13361 1 sidestep=1;
13362
4/6
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
88 else if(iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13363 sidestep=2;
13364
13365
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 88 times.
89 if(sidestep==1) x++;
13366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 else if(sidestep==2) x--;
13367 88 else y--;
13368
13369
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 4 times.
89 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13370 {
13371 4 hopclk=0xFF;
13372 4 diveclk=0;
13373 4 SetSwim();
13374 4 }
13375 89 }
13376
13377
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 142 times.
643 if(dir==down)
13378 {
13379 142 herostep();
13380 142 herostep();
13381 142 int32_t sidestep=0;
13382
13383
3/6
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 142 times.
142 if(!iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13384 sidestep=1;
13385
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
142 else if(iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13386 sidestep=2;
13387
13388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(sidestep==1) x++;
13389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(sidestep==2) x--;
13390 142 else y++;
13391
13392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13393 {
13394 hopclk=0xFF;
13395 diveclk=0;
13396 SetSwim();
13397 if (!IsSideSwim()) reset_swordcharge();
13398 }
13399 142 }
13400
13401
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 133 times.
643 if(dir==left)
13402 {
13403 133 herostep();
13404 133 herostep();
13405 133 int32_t sidestep=0;
13406
13407
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?8:12)), -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13408 sidestep=1;
13409
4/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
133 else if(iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?7:11)), -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13410 sidestep=2;
13411
13412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(sidestep==1) y++;
13413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 else if(sidestep==2) y--;
13414 133 else x--;
13415
13416
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 95 times.
133 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13417 {
13418 7 hopclk=0xFF;
13419 7 diveclk=0;
13420 7 SetSwim();
13421 7 }
13422 133 }
13423
13424
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 279 times.
643 if(dir==right)
13425 {
13426 279 herostep();
13427 279 herostep();
13428
13429 279 int32_t sidestep=0;
13430
13431
4/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
279 if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?8:12)), -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13432 sidestep=1;
13433
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 279 times.
✗ Branch 5 not taken.
279 else if(iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?7:11)), -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13434 sidestep=2;
13435
13436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(sidestep==1) y++;
13437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 else if(sidestep==2) y--;
13438 279 else x++;
13439
13440
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
279 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13441 {
13442 5 hopclk=0xFF;
13443 5 diveclk=0;
13444 5 SetSwim();
13445 5 }
13446 279 }
13447 643 }
13448
13449 1018 }
13450 else
13451 {
13452
7/8
✓ Branch 0 taken 4823 times.
✓ Branch 1 taken 7686 times.
✓ Branch 2 taken 4823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3622 times.
✓ Branch 5 taken 1201 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 7046 times.
12509 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
13453 {
13454 1201 action=none; FFCore.setHeroAction(none);
13455 1201 hopclk = 0;
13456 1201 diveclk = 0;
13457
13458
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 625 times.
1201 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+8), -1, x.getInt(),y.getInt()+8, true, false))
13459 {
13460 // hopped in
13461 625 SetSwim();
13462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!IsSideSwim()) attackclk = charging = spins = 0;
13463 625 }
13464 1201 }
13465 else
13466 {
13467 11308 herostep();
13468 11308 herostep();
13469
13470
2/2
✓ Branch 0 taken 10642 times.
✓ Branch 1 taken 666 times.
11308 if(++hero_count>(16*hero_animation_speed))
13471 666 hero_count=0;
13472
13473 11308 int32_t xofs2 = x.getInt()&15;
13474 11308 int32_t yofs2 = y.getInt()&15;
13475 11308 int32_t s = 1 + (frame&1);
13476
13477
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 2606 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 3644 times.
11308 switch(dir)
13478 {
13479 case up:
13480
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 1167 times.
✓ Branch 3 taken 6 times.
1656 if(yofs2<3 || yofs2>13) --y;
13481 1167 else y-=s;
13482
13483 1656 break;
13484
13485 case down:
13486
4/4
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 356 times.
✓ Branch 3 taken 1796 times.
2606 if(yofs2<3 || yofs2>13) ++y;
13487 1796 else y+=s;
13488
13489 2606 break;
13490
13491 case left:
13492
4/4
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 2368 times.
3402 if(xofs2<3 || xofs2>13) --x;
13493 2368 else x-=s;
13494
13495 3402 break;
13496
13497 case right:
13498
4/4
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 635 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2517 times.
3644 if(xofs2<3 || xofs2>13) ++x;
13499 2517 else x+=s;
13500
13501 3644 break;
13502 }
13503 }
13504 }
13505 }
13506 14081 }
13507
13508 113150 void HeroClass::do_rafting()
13509 {
13510
13511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(toogam)
13512 {
13513 action=none; FFCore.setHeroAction(none);
13514 return;
13515 }
13516
13517 113150 FFCore.setHeroAction(rafting);
13518
13519 113150 do_lens();
13520
13521 113150 herostep();
13522
13523 //Calculate rafting speed
13524 113150 int32_t raft_item = current_item_id(itype_raft);
13525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
13526 113150 raft_step = vbound(raft_step, -8, 5);
13527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
13528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(raft_step < 0) raft_step = 1;
13529 113150 int32_t step_inc = 1 << (raft_step - 1);
13530 // Fix position
13531
1/2
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
113150 if(raft_step > 1)
13532 {
13533 if(x.getInt() & (step_inc-1))
13534 {
13535 x = x.getInt() & ~(step_inc-1);
13536 }
13537 if(y.getInt() & (step_inc-1))
13538 {
13539 y = y.getInt() & ~(step_inc-1);
13540 }
13541 }
13542 // Inc clock, check if we need to move this frame
13543 113150 ++raftclk;
13544
2/4
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113150 times.
113150 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13545
13546
4/4
✓ Branch 0 taken 54339 times.
✓ Branch 1 taken 58811 times.
✓ Branch 2 taken 46510 times.
✓ Branch 3 taken 7829 times.
120836 if(!(x.getInt()&15) && !(y.getInt()&15))
13547 {
13548 // this sections handles switching to raft branches
13549
3/4
✓ Branch 0 taken 7575 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7829 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13550 {
13551
7/8
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
254 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13552 {
13553 35 dir = up;
13554 35 goto skip;
13555 }
13556
13557
7/8
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
219 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13558 {
13559 48 dir = down;
13560 48 goto skip;
13561 }
13562
13563
7/8
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
171 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13564 {
13565 31 dir = left;
13566 31 goto skip;
13567 }
13568
13569
7/8
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
140 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13570 {
13571 29 dir = right;
13572 29 goto skip;
13573 }
13574 111 }
13575
2/4
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7575 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13576 {
13577 if(dir == left) dir = right;
13578 else if(dir == right) dir = left;
13579 else if(dir == up) dir = down;
13580 else if(dir == down) dir = up;
13581 }
13582
13583
4/4
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 6304 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1371 times.
7686 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13584 {
13585
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 632 times.
1371 if(dir<left) //going up or down
13586 {
13587
3/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470 times.
739 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13588 269 dir=right;
13589
3/4
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 241 times.
470 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13590 229 dir=left;
13591
4/4
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 16 times.
241 else if(y>0 && y<world_h-16)
13592 {
13593 210 action=none; FFCore.setHeroAction(none);
13594 210 x = x.getInt();
13595 210 y = y.getInt();
13596 210 }
13597 739 }
13598 else //going left or right
13599 {
13600
3/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
632 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13601 243 dir=down;
13602
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
389 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13603 242 dir=up;
13604
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 145 times.
147 else if(x>0 && x<world_w-16)
13605 {
13606 145 action=none; FFCore.setHeroAction(none);
13607 145 x = x.getInt();
13608 145 y = y.getInt();
13609 145 }
13610 }
13611 1371 }
13612 7686 }
13613
13614 skip:
13615
13616
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25101 times.
✓ Branch 2 taken 24965 times.
✓ Branch 3 taken 29470 times.
✓ Branch 4 taken 33614 times.
113150 switch(dir)
13617 {
13618 case up:
13619
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 25092 times.
25101 if(x.getInt()&15)
13620 {
13621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(x.getInt()&8)
13622 x++;
13623 9 else x--;
13624 9 }
13625 25092 else y -= step_inc;
13626
13627 25101 break;
13628
13629 case down:
13630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24965 times.
24965 if(x.getInt()&15)
13631 {
13632 if(x.getInt()&8)
13633 x++;
13634 else x--;
13635 }
13636 24965 else y += step_inc;
13637
13638 24965 break;
13639
13640 case left:
13641
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 29464 times.
29470 if(y.getInt()&15)
13642 {
13643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (get_qr(qr_BETTER_RAFT_2))
13644 {
13645 if ((y.getInt() % 16) < 4) y--;
13646 else y++;
13647 }
13648 else
13649 {
13650
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(y.getInt()&8)
13651 6 y++;
13652 else y--;
13653 }
13654 6 }
13655 29464 else x -= step_inc;
13656
13657 29470 break;
13658
13659 case right:
13660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33614 times.
33614 if(y.getInt()&15)
13661 {
13662 if (get_qr(qr_BETTER_RAFT_2))
13663 {
13664 if ((y.getInt() % 16) <= 4) y--;
13665 else y++;
13666 }
13667 else
13668 {
13669 if(y.getInt()&8)
13670 y++;
13671 else y--;
13672 }
13673 }
13674 33614 else x += step_inc;
13675
13676 33614 break;
13677 }
13678 113150 }
13679
13680 253 bool HeroClass::try_hover()
13681 {
13682
6/10
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 251 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
253 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13683 {
13684 2 int32_t itemid = current_item_id(itype_hoverboots);
13685
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13686 hoverclk = -hoverclk;
13687 else
13688 {
13689 2 fall = fakefall = jumping = 0;
13690
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13691 2 hoverclk = itemsbuf[itemid].misc1;
13692 else
13693 {
13694 hoverclk = 1;
13695 hoverflags |= HOV_INF;
13696 }
13697
13698
13699 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13700 }
13701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13702
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13703 2 return true;
13704 }
13705 251 return false;
13706 253 }
13707
13708 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13709 //Returns '-1' if not being pulled
13710 //Returns '-2' if should be falling in
13711 40394298 int32_t HeroClass::check_pitslide(bool ignore_hover)
13712 {
13713 //Pitfall todo -Emily
13714 //Iron boots; can't fight slipping, 2px/frame
13715 //Scripted variables to read pull dir/clk (clk only for non-hero)
13716 //Implement falling for all sprite types (npc AI)
13717 // Fall/slipping tiles for enemies
13718 // Fall/slipping SFX for enemies
13719 // Fall SFX for items/weapons
13720 // Weapons/Misc sprite shared for falling items/weapons
13721 //Maybe slip SFX for Hero?
13722 // Weapons/Misc sprite override for falling sprite?
13723 //Update std.zh with relevant new stuff
13724
2/2
✓ Branch 0 taken 1202934 times.
✓ Branch 1 taken 39191364 times.
40394298 if(can_pitfall(ignore_hover))
13725 {
13726
3/4
✓ Branch 0 taken 12630746 times.
✓ Branch 1 taken 26560618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26560618 times.
39191364 bool can_diag = (diagonalMovement || NO_GRIDLOCK);
13727 39191364 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13728 39191364 int32_t ispitbl = getpitfall(x,y+15);
13729 39191364 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13730 39191364 int32_t ispitbr = getpitfall(x+15,y+15);
13731 39191364 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13732 39191364 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13733 39191364 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13734 39191364 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13735 39191364 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13736 39191364 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13737 39191364 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13738 39191364 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13739 static const int32_t flag_pit_irresistable = (1<<24);
13740
5/5
✓ Branch 0 taken 39142507 times.
✓ Branch 1 taken 3673 times.
✓ Branch 2 taken 666 times.
✓ Branch 3 taken 26542 times.
✓ Branch 4 taken 17976 times.
39191364 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13741 {
13742 3673 case 4: return -2; //Fully over pit; fall in
13743 case 3:
13744 {
13745
6/6
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 202 times.
✓ Branch 5 taken 16 times.
666 if(ispitul && ispitur && ispitbl) //UL_3
13746 {
13747
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(ispitul_50)
13748 {
13749
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13750 3 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13751 }
13752 }
13753
5/6
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 202 times.
✓ Branch 3 taken 118 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 202 times.
650 else if(ispitul && ispitur && ispitbr) //UR_3
13754 {
13755
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 172 times.
202 if(ispitur_50)
13756 {
13757
5/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
30 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13758 18 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13759 }
13760 172 }
13761
4/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 118 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 118 times.
448 else if(ispitul && ispitbl && ispitbr) //BL_3
13762 {
13763
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 108 times.
118 if(ispitbl_50)
13764 {
13765
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
10 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13766 10 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13767 }
13768 108 }
13769
3/6
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 330 times.
330 else if(ispitbl && ispitur && ispitbr) //BR_3
13770 {
13771
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 328 times.
330 if(ispitbr_50)
13772 {
13773
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13774 2 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13775 }
13776 328 }
13777 608 break;
13778 }
13779 case 2:
13780 {
13781
4/4
✓ Branch 0 taken 13871 times.
✓ Branch 1 taken 12671 times.
✓ Branch 2 taken 11998 times.
✓ Branch 3 taken 1873 times.
26542 if(ispitul && ispitur) //Up
13782 {
13783
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 1786 times.
1873 if(DrunkDown())
13784 {
13785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
87 if(ispitul_75 && ispitur_75) //Straight up
13786 {
13787 return up | flag_pit_irresistable | (ispitul << 8);
13788 }
13789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 else if(ispitul_75)
13790 {
13791 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13792 }
13793
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 else if(ispitur_75)
13794 {
13795 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13796 }
13797 87 else return -1;
13798 }
13799 else
13800 {
13801
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 1631 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 155 times.
1786 if(ispitul_50 && ispitur_50) //Straight up
13802 {
13803
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 100 times.
155 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13804 }
13805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1631 times.
1631 else if(ispitul_50)
13806 {
13807 if(DrunkRight() && !ispitul_75) return -1;
13808 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13809 }
13810
1/2
✓ Branch 0 taken 1631 times.
✗ Branch 1 not taken.
1631 else if(ispitur_50)
13811 {
13812 if(DrunkLeft() && !ispitur_75) return -1;
13813 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13814 }
13815 }
13816 1631 }
13817
4/4
✓ Branch 0 taken 14204 times.
✓ Branch 1 taken 10465 times.
✓ Branch 2 taken 11986 times.
✓ Branch 3 taken 2218 times.
24669 else if(ispitbl && ispitbr) //Down
13818 {
13819
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 2162 times.
2218 if(DrunkUp())
13820 {
13821
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
56 if(ispitbl_75 && ispitbr_75) //Straight down
13822 {
13823 3 return down | flag_pit_irresistable | (ispitbl << 8);
13824 }
13825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 else if(ispitbl_75)
13826 {
13827 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13828 }
13829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 else if(ispitbr_75)
13830 {
13831 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13832 }
13833 53 else return -1;
13834 }
13835 else
13836 {
13837
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2127 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
2162 if(ispitbl_50 && ispitbr_50) //Straight down
13838 {
13839
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 27 times.
35 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13840 }
13841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 else if(ispitbl_50)
13842 {
13843 if(DrunkRight() && !ispitbl_75) return -1;
13844 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13845 }
13846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 else if(ispitbr_50)
13847 {
13848 if(DrunkLeft() && !ispitbr_75) return -1;
13849 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13850 }
13851 }
13852 2127 }
13853
3/4
✓ Branch 0 taken 11986 times.
✓ Branch 1 taken 10465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11986 times.
22451 else if(ispitbl && ispitul) //Left
13854 {
13855
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 11359 times.
11986 if(DrunkRight())
13856 {
13857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
627 if(ispitul_75 && ispitbl_75) //Straight left
13858 {
13859 return left | flag_pit_irresistable | (ispitul << 8);
13860 }
13861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
627 else if(ispitul_75)
13862 {
13863 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13864 }
13865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
627 else if(ispitbl_75)
13866 {
13867 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13868 }
13869 627 else return -1;
13870 }
13871 else
13872 {
13873
3/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 11044 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
11359 if(ispitul_50 && ispitbl_50) //Straight left
13874 {
13875
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 231 times.
315 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13876 }
13877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11044 times.
11044 else if(ispitul_50)
13878 {
13879 if(DrunkDown() && !ispitul_75) return -1;
13880 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13881 }
13882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11044 times.
11044 else if(ispitbl_50)
13883 {
13884 if(DrunkUp() && !ispitbl_75) return -1;
13885 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13886 }
13887 }
13888 11044 }
13889
3/4
✓ Branch 0 taken 10465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 10453 times.
10465 else if(ispitbr && ispitur) //Right
13890 {
13891
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 9875 times.
10453 if(DrunkLeft())
13892 {
13893
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
578 if(ispitur_75 && ispitbr_75) //Straight right
13894 {
13895 13 return right | flag_pit_irresistable | (ispitur << 8);
13896 }
13897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ispitur_75)
13898 {
13899 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13900 }
13901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ispitbr_75)
13902 {
13903 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13904 }
13905 565 else return -1;
13906 }
13907 else
13908 {
13909
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 9536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
9875 if(ispitur_50 && ispitbr_50) //Straight right
13910 {
13911
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 117 times.
339 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13912 }
13913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9536 times.
9536 else if(ispitur_50)
13914 {
13915 if(DrunkDown() && !ispitur_75) return -1;
13916 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13917 }
13918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9536 times.
9536 else if(ispitbr_50)
13919 {
13920 if(DrunkUp() && !ispitbr_75) return -1;
13921 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13922 }
13923 }
13924 9536 }
13925 24350 break;
13926 }
13927 case 1:
13928 {
13929
4/4
✓ Branch 0 taken 5636 times.
✓ Branch 1 taken 12340 times.
✓ Branch 2 taken 5633 times.
✓ Branch 3 taken 3 times.
17976 if(ispitul && ispitul_50) //UL_1
13930 {
13931
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13932 3 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13933 }
13934
4/4
✓ Branch 0 taken 4168 times.
✓ Branch 1 taken 13805 times.
✓ Branch 2 taken 4116 times.
✓ Branch 3 taken 52 times.
17973 if(ispitur && ispitur_50) //UR_1
13935 {
13936
5/6
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 9 times.
52 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13937 9 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13938 }
13939
4/4
✓ Branch 0 taken 3253 times.
✓ Branch 1 taken 14668 times.
✓ Branch 2 taken 3251 times.
✓ Branch 3 taken 2 times.
17921 if(ispitbl && ispitbl_50) //BL_1
13940 {
13941
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13942 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13943 }
13944
4/4
✓ Branch 0 taken 4919 times.
✓ Branch 1 taken 13000 times.
✓ Branch 2 taken 4877 times.
✓ Branch 3 taken 42 times.
17919 if(ispitbr && ispitbr_50) //BR_1
13945 {
13946
5/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 4 times.
42 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13947 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13948 }
13949 17877 break;
13950 }
13951 }
13952 39185342 }
13953 40388276 return -1;
13954 40394298 }
13955
13956 11975057 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13957 {
13958 11975057 pitfall();
13959
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 11975040 times.
11975057 if(fallclk) return true;
13960 11975040 int32_t val = check_pitslide();
13961 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13962
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 11974838 times.
11975040 if(val == -1)
13963 {
13964 11974838 pit_pulldir = -1;
13965 11974838 pit_pullclk = 0;
13966 11974838 return false;
13967 }
13968 202 int32_t dir = val&0xFF;
13969 202 int32_t cmbid = (val&0xFFFF00)>>8;
13970 202 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202 times.
202 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13972 {
13973 pit_pulldir = -1;
13974 pit_pullclk = 0;
13975 return false;
13976 }
13977
4/6
✓ Branch 0 taken 202 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 2 times.
202 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13978 {
13979 2 pit_pulldir = -1;
13980 2 pit_pullclk = 0;
13981 2 return false;
13982 }
13983 200 pit_pulldir = dir;
13984 200 int32_t step = 1;
13985
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 10 times.
200 if(sensitivity == 0)
13986 {
13987 10 step = 2;
13988 10 sensitivity = 1;
13989 10 }
13990
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 152 times.
200 if(pit_pullclk++ % sensitivity) //No pull this frame
13991 48 return (val&0x100);
13992
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 152 times.
312 for(; step > 0 && !fallclk; --step)
13993 {
13994
3/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 40 times.
160 switch(dir)
13995 {
13996 case l_up: case l_down: case left:
13997 52 --x; break;
13998 case r_up: case r_down: case right:
13999 68 ++x; break;
14000 }
14001
3/3
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 112 times.
160 switch(dir)
14002 {
14003 case l_up: case r_up: case up:
14004 37 --y; break;
14005 case l_down: case r_down: case down:
14006 11 ++y; break;
14007 }
14008 160 pitfall();
14009 160 }
14010
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 34 times.
152 return fallclk || (val&0x100);
14011 11975057 }
14012
14013 11978787 void HeroClass::pitfall()
14014 {
14015
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 11975217 times.
11978787 if(fallclk)
14016 {
14017 3570 drop_liftwpn();
14018
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 3519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
3570 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
14019 //Handle falling
14020
2/2
✓ Branch 0 taken 3519 times.
✓ Branch 1 taken 51 times.
3570 if(!--fallclk)
14021 {
14022 51 optional<combined_handle_t> comb_handle;
14023
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 if((comb_handle = get_pitfall_handle(x+8, y+(bigHitbox?8:12))) && comb_handle->data() == fallCombo) /*nil*/;
14024 else if((comb_handle = get_pitfall_handle(x+8, y+(bigHitbox?0:8))) && comb_handle->data() == fallCombo) /*nil*/;
14025 else if((comb_handle = get_pitfall_handle(x+15, y+(bigHitbox?0:8))) && comb_handle->data() == fallCombo) /*nil*/;
14026 else if((comb_handle = get_pitfall_handle(x, y+15)) && comb_handle->data() == fallCombo) /*nil*/;
14027 else if((comb_handle = get_pitfall_handle(x+15, y+15)) && comb_handle->data() == fallCombo) /*nil*/;
14028 else comb_handle = nullopt; // nothing found, no `CType Causes->`
14029
14030 51 std::vector<int32_t> &ev = FFCore.eventData;
14031 51 ev.clear();
14032 51 ev.push_back(fallCombo*10000);
14033
14034 51 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
14035
14036 51 fallCombo = ev[0]/10000;
14037
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
51 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
14038 fallCombo = 0;
14039
14040 51 int32_t dmg = game->get_hp_per_heart()/4;
14041 51 bool dmg_perc = false;
14042 51 bool warp = false;
14043
14044 51 action=none; FFCore.setHeroAction(none);
14045
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
14046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(cmb)
14047 {
14048 51 dmg = cmb->attributes[0]/10000L;
14049 51 dmg_perc = cmb->usrflags&cflag3;
14050 51 warp = cmb->usrflags&cflag1;
14051 51 }
14052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if(cheat_superman && dmg > 0)
14053 dmg = 0;
14054
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 38 times.
51 if(dmg) //Damage
14055 {
14056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(dmg > 0)
14057 {
14058 38 hclk=48; //IFrames only if damaged, not if healed
14059 38 check_on_hit();
14060 38 }
14061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
14062 38 }
14063
14064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(comb_handle)
14065 51 do_trigger_ctype_causes(*comb_handle);
14066
14067
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 47 times.
51 if(warp) //Warp
14068 {
14069 4 sdir = dir;
14070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb->usrflags&cflag2) //Direct Warp
14071 {
14072 4 setpit();
14073 4 }
14074 4 dowarp(hero_scr, 0, vbound(cmb->attribytes[1],0,3), 0);
14075 4 }
14076 else //Reset to screen entry
14077 {
14078 47 go_respawn_point();
14079 }
14080 51 }
14081 3570 }
14082
2/2
✓ Branch 0 taken 437762 times.
✓ Branch 1 taken 11537455 times.
11975217 else if(can_pitfall())
14083 {
14084 11537455 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
14085 11537455 bool ispitbl = ispitfall(x,y+15);
14086 11537455 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
14087 11537455 bool ispitbr = ispitfall(x+15,y+15);
14088 11537455 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
14089
9/10
✓ Branch 0 taken 4581 times.
✓ Branch 1 taken 11532874 times.
✓ Branch 2 taken 2849 times.
✓ Branch 3 taken 1732 times.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 2795 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 51 times.
11537455 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
14090 {
14091
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
14092
3/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 41 times.
51 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
14093 51 fallclk = PITFALL_FALL_FRAMES;
14094 51 fallCombo = pitctr;
14095 51 action=falling; FFCore.setHeroAction(falling);
14096 51 spins = 0;
14097 51 charging = 0;
14098 51 drop_liftwpn();
14099 51 }
14100 11537455 }
14101 11978787 }
14102
14103 160 void HeroClass::handle_slide(newcombo const& icecmb, zfix& dx, zfix& dy)
14104 {
14105
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 bool is_inair = z || fakez;
14106 160 zfix odx = dx, ody = dy;
14107
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 155 times.
✗ Branch 3 not taken.
160 if(sliding == 2 && !is_inair) //landed from air-sliding
14108 {
14109 if((ice_vx+odx).sign() != ice_vx.sign())
14110 ice_vx = 0;
14111 if((ice_vy+ody).sign() != ice_vy.sign())
14112 ice_vy = 0;
14113 sliding = 1;
14114 }
14115
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(!sliding) //just hit the ice
14116 {
14117 if(is_inair)
14118 return;
14119 sliding = 1;
14120 zfix start_perc = icecmb.attribytes[0] / 100_zf;
14121 ice_vx = dx * start_perc;
14122 ice_vy = dy * start_perc;
14123 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
14124 }
14125 else //not the first frame sliding
14126 {
14127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(is_inair)
14128 160 sliding = 2;
14129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 zfix accel = zslongToFix(zc_max(1,icecmb.attributes[0]));
14130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 zfix decel = zslongToFix(zc_max(1,icecmb.attributes[1]));
14131
14132
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(ice_entry_count)
14133 {
14134 if(--ice_entry_count)
14135 {
14136 zfix perc = zfix(ice_entry_count)/ice_entry_mcount;
14137 perc *= perc; //square the portion, for a better transition
14138 zfix normal_rate = zfix(steprate)/100/2;
14139 decel = (perc*normal_rate)+((1-perc)*decel);
14140 }
14141 }
14142 //!TODO Traction Boots can be added here, with a multiplier on accel/decel
14143 //Accelerate in the pushed direction
14144
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(is_inair)
14145 {
14146 static const int air_accel = 100;
14147 160 accel = abs(odx)/air_accel;
14148
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(accel)
14149 {
14150 if(odx < 0)
14151 {
14152 if(ice_vx - accel < odx)
14153 {
14154 if(ice_vx > odx)
14155 ice_vx = odx;
14156 else odx = 0; //allow decel
14157 }
14158 else ice_vx -= accel;
14159 }
14160 else //if(odx > 0)
14161 {
14162 if(ice_vx + accel > odx)
14163 {
14164 if(ice_vx < odx)
14165 ice_vx = odx;
14166 else odx = 0; //allow decel
14167 }
14168 else ice_vx += accel;
14169 }
14170 }
14171 160 accel = abs(ody)/air_accel;
14172
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(accel)
14173 {
14174 if(ody < 0)
14175 {
14176 if(ice_vy - accel < ody)
14177 {
14178 if(ice_vy > ody)
14179 ice_vy = ody;
14180 else ody = 0; //allow decel
14181 }
14182 else ice_vy -= accel;
14183 }
14184 else //if(ody > 0)
14185 {
14186 if(ice_vy + accel > ody)
14187 {
14188 if(ice_vy < ody)
14189 ice_vy = ody;
14190 else ody = 0; //allow decel
14191 }
14192 else ice_vy += accel;
14193 }
14194 }
14195 160 }
14196 else if(accel)
14197 {
14198 if(odx > 0)
14199 ice_vx += accel;
14200 else if(odx < 0)
14201 ice_vx -= accel;
14202 if(ody > 0)
14203 ice_vy += accel;
14204 else if(ody < 0)
14205 ice_vy -= accel;
14206 }
14207 //Decelerate in non-pushed direction
14208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(is_inair)
14209 160 decel = zinit.air_drag;
14210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(decel)
14211 {
14212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(ice_vx)
14213 {
14214
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!odx && abs(ice_vx) < decel)
14215 ice_vx = 0;
14216
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
160 else if(ice_vx > 0 && odx <= 0)
14217 96 ice_vx -= decel;
14218
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 else if(ice_vx < 0 && odx >= 0)
14219 64 ice_vx += decel;
14220 160 }
14221
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(ice_vy)
14222 {
14223 if(!ody && abs(ice_vy) < decel)
14224 ice_vy = 0;
14225 else if(ice_vy > 0 && ody <= 0)
14226 ice_vy -= decel;
14227 else if(ice_vy < 0 && ody >= 0)
14228 ice_vy += decel;
14229 }
14230 160 }
14231 }
14232
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
14233 160 dx = ice_vx = vbound(ice_vx, -cap, cap);
14234 160 dy = ice_vy = vbound(ice_vy, -cap, cap);
14235
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if(!dx && !dy)
14236 ice_entry_count = 0;
14237 160 }
14238 257218 void HeroClass::mod_steps(std::vector<zfix*>& v)
14239 {
14240
3/4
✓ Branch 0 taken 256544 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 256544 times.
✗ Branch 3 not taken.
257218 bool can_combo = ((z==0 && fakez==0) || hero_scr->flags2&fAIRCOMBOS);
14241
4/6
✓ Branch 0 taken 21068 times.
✓ Branch 1 taken 236150 times.
✓ Branch 2 taken 21068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21068 times.
✗ Branch 5 not taken.
493368 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
14242
5/6
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 235389 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
236150 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
14243 //!DIMITODO: add QR for slow combos under hero
14244
4/4
✓ Branch 0 taken 236150 times.
✓ Branch 1 taken 21068 times.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 42136 times.
299354 if(slowcombo) for (int32_t i = 1; i <= 2; ++i)
14245 {
14246
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 41180 times.
42136 if (get_scr_layer_valid(hero_screen, i))
14247 {
14248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41180 times.
41180 if (get_qr(qr_OLD_BRIDGE_COMBOS))
14249 {
14250 if (combobuf[MAPCOMBO2(i-1, x+7, y+8)].type == cBRIDGE && !_walkflag_layer(x+7, y+8, i))
14251 {
14252 slowcombo = false;
14253 break;
14254 }
14255 }
14256 else
14257 {
14258
2/4
✓ Branch 0 taken 41180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41180 times.
✗ Branch 3 not taken.
41180 if (combobuf[MAPCOMBO2(i-1, x+7, y+8)].type == cBRIDGE && _effectflag_layer(x+7, y+8, i))
14259 {
14260 slowcombo = false;
14261 break;
14262 }
14263 }
14264 41180 }
14265 63204 }
14266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
257218 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
14267 257218 bool is_swimming = (action == swimming);
14268 257218 int32_t shieldid = getCurrentActiveShield();
14269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
257218 if(shieldid > -1)
14270 {
14271 itemdata const& shield = itemsbuf[shieldid];
14272 if(shield.flags & item_flag10) //Change Speed flag
14273 {
14274 zfix perc = shield.misc7;
14275 perc /= 100;
14276 if(perc < 0)
14277 perc = (perc*-1)+1;
14278 zfix add(shield.misc8);
14279 add /= 100;
14280 for(zfix* stp : v)
14281 {
14282 zfix& pix = *stp;
14283 pix = (pix * perc) + add;
14284 }
14285 }
14286 }
14287
14288
2/2
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 256544 times.
257218 if (can_combo)
14289 {
14290 256544 rpos_t slow_rpos = COMBOPOS_REGION_B(x+7, y+8);
14291
2/2
✓ Branch 0 taken 255966 times.
✓ Branch 1 taken 1794863 times.
2050829 for (int q = 6; q >= 0; --q)
14292 {
14293
1/2
✓ Branch 0 taken 1794863 times.
✗ Branch 1 not taken.
1794863 if (slow_rpos == rpos_t::None) break;
14294 1794863 auto& cmb = get_rpos_handle(slow_rpos, q).combo();
14295
14296
3/6
✓ Branch 0 taken 1794774 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1794774 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1794863 if (cmb.speed_mult != 1 || cmb.speed_div || cmb.speed_add)
14297 {
14298
2/2
✓ Branch 0 taken 8974315 times.
✓ Branch 1 taken 1794863 times.
10769178 for (zfix* stp : v)
14299 {
14300 8974315 zfix& pix = *stp;
14301 8974315 pix *= cmb.speed_mult;
14302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8974315 times.
8974315 if(cmb.speed_div)
14303 8974315 pix /= cmb.speed_div;
14304 8974315 pix += cmb.speed_add;
14305 }
14306 1794863 }
14307
14308
4/4
✓ Branch 0 taken 1538897 times.
✓ Branch 1 taken 255966 times.
✓ Branch 2 taken 1538319 times.
✓ Branch 3 taken 578 times.
1794863 if (q > 0 && cmb.type == cBRIDGE)
14309 {
14310
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
✓ Branch 2 taken 578 times.
✗ Branch 3 not taken.
578 if(get_qr(qr_OLD_BRIDGE_COMBOS)
14311 ? !_walkflag_layer(x+7,y+8,q-1)
14312 578 : _effectflag_layer(x+7,y+8,q-1))
14313 {
14314 578 break; //Bridge blocks speed change from below it
14315 }
14316 }
14317 1794285 }
14318 256544 }
14319
14320 257218 zfix mult = 1, div = 1;
14321
2/2
✓ Branch 0 taken 6290 times.
✓ Branch 1 taken 250928 times.
257218 if(is_swimming)
14322 {
14323 6290 mult = game->swim_mult;
14324 6290 div = game->swim_div;
14325 6290 }
14326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250928 else if(slowcharging && slowcombo) //1/2 speed
14327 {
14328 div = 2;
14329 }
14330
3/4
✓ Branch 0 taken 250928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 229860 times.
250928 else if(slowcharging || slowcombo) //2/3 speed
14331 {
14332 21068 mult = 2;
14333 21068 div = 3;
14334 21068 }
14335
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 if(!div) div = 1;
14336
3/4
✓ Branch 0 taken 229860 times.
✓ Branch 1 taken 27358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229860 times.
257218 if(mult != 1 || div != 1)
14337 {
14338
2/2
✓ Branch 0 taken 136790 times.
✓ Branch 1 taken 27358 times.
164148 for(zfix* stp : v)
14339 {
14340 136790 zfix& pix = *stp;
14341 136790 pix = ((pix / div) * mult);
14342 }
14343 27358 }
14344 257218 }
14345
14346 13300107 void HeroClass::moveheroOld()
14347 {
14348
4/4
✓ Branch 0 taken 13292268 times.
✓ Branch 1 taken 7839 times.
✓ Branch 2 taken 7584 times.
✓ Branch 3 taken 13285020 times.
13300107 if(lstunclock || is_conveyor_stunned) return;
14349 13285020 int32_t xoff=x.getInt()&7;
14350 13285020 int32_t yoff=y.getInt()&7;
14351
4/4
✓ Branch 0 taken 13102220 times.
✓ Branch 1 taken 182800 times.
✓ Branch 2 taken 23246 times.
✓ Branch 3 taken 13125466 times.
13285020 if(NO_GRIDLOCK)
14352 {
14353 206046 xoff = 0;
14354 206046 yoff = 0;
14355 206046 }
14356 13315514 int32_t push=pushing;
14357 13315514 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
14358 13315514 pushing=0;
14359 13315514 zfix temp_step(hero_newstep);
14360 13315514 zfix temp_x(x);
14361 13315514 zfix temp_y(y);
14362
14363 13315514 int32_t flippers_id = current_item_id(itype_flippers);
14364 13315514 itemdata const& itm = itemsbuf[flippers_id];
14365 13315514 byte intbtn = byte(itm.misc3&0xFF);
14366 13315514 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
14367 13315514 bool eatdive = false;
14368
2/2
✓ Branch 0 taken 37580 times.
✓ Branch 1 taken 13277934 times.
13315514 if(diveclk>0)
14369 {
14370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37580 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
14371 37580 --diveclk;
14372
4/8
✓ Branch 0 taken 9502 times.
✓ Branch 1 taken 28078 times.
✓ Branch 2 taken 9502 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9502 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37580 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
14373 {
14374 diveclk = itemsbuf[flippers_id].misc2;
14375 eatdive = true;
14376 }
14377 37580 }
14378
4/4
✓ Branch 0 taken 113504 times.
✓ Branch 1 taken 13164430 times.
✓ Branch 2 taken 113277 times.
✓ Branch 3 taken 227 times.
13277934 else if(action == swimming && dive_pressed)
14379 {
14380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
14381 227 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
14382
14383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(global_diving==screen_diving)
14384 {
14385
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
14386 227 eatdive = true;
14387 227 }
14388 227 }
14389
2/2
✓ Branch 0 taken 13315287 times.
✓ Branch 1 taken 227 times.
13315514 if(eatdive)
14390 227 getIntBtnInput(intbtn, true, true, false, false, false);
14391
14392
2/2
✓ Branch 0 taken 13202364 times.
✓ Branch 1 taken 113150 times.
13315514 if(action==rafting)
14393 {
14394 113150 do_rafting();
14395
14396
2/2
✓ Branch 0 taken 112795 times.
✓ Branch 1 taken 355 times.
113150 if(action==rafting)
14397 {
14398 112795 return;
14399 }
14400
14401
14402 355 set_respawn_point();
14403 355 trySideviewLadder();
14404 355 }
14405
14406 13202719 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
14407 13202719 int32_t btnwpn = -1;
14408
14409 //&0xFFF removes the "bow & arrows" bitmask
14410 //The Quick Sword is allowed to interrupt attacks.
14411
4/4
✓ Branch 0 taken 13027963 times.
✓ Branch 1 taken 174756 times.
✓ Branch 2 taken 8823053 times.
✓ Branch 3 taken 4204910 times.
13202719 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
14412
8/8
✓ Branch 0 taken 11570434 times.
✓ Branch 1 taken 1632285 times.
✓ Branch 2 taken 11559088 times.
✓ Branch 3 taken 11346 times.
✓ Branch 4 taken 390563 times.
✓ Branch 5 taken 1253068 times.
✓ Branch 6 taken 72183 times.
✓ Branch 7 taken 1571448 times.
13202719 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
14413 {
14414
2/2
✓ Branch 0 taken 29031 times.
✓ Branch 1 taken 11602240 times.
11631271 if(DrunkrBbtn())
14415 {
14416 29031 btnwpn=getItemFamily(itemsbuf,Bwpn);
14417
2/2
✓ Branch 0 taken 28827 times.
✓ Branch 1 taken 204 times.
29031 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
14418 29031 directWpn = directItemB;
14419 29031 }
14420
2/2
✓ Branch 0 taken 89955 times.
✓ Branch 1 taken 11512285 times.
11602240 else if(DrunkrAbtn())
14421 {
14422 89955 btnwpn=getItemFamily(itemsbuf,Awpn);
14423
2/2
✓ Branch 0 taken 87154 times.
✓ Branch 1 taken 2801 times.
89955 dowpn = NEG_OR_MASK(Awpn,0xFFF);
14424 89955 directWpn = directItemA;
14425 89955 }
14426
4/4
✓ Branch 0 taken 197564 times.
✓ Branch 1 taken 11314721 times.
✓ Branch 2 taken 197488 times.
✓ Branch 3 taken 76 times.
11512285 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
14427 {
14428 76 btnwpn=getItemFamily(itemsbuf,Xwpn);
14429
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
14430 76 directWpn = directItemX;
14431 76 }
14432
4/4
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 11314721 times.
✓ Branch 2 taken 197363 times.
✓ Branch 3 taken 125 times.
11512209 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
14433 {
14434 125 btnwpn=getItemFamily(itemsbuf,Ywpn);
14435
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
14436 125 directWpn = directItemY;
14437 125 }
14438
14439
1/2
✓ Branch 0 taken 11631271 times.
✗ Branch 1 not taken.
11631271 if(directWpn >= MAXITEMS) directWpn = -1;
14440
14441 // The Quick Sword only allows repeated sword or wand swings.
14442
7/8
✓ Branch 0 taken 11559088 times.
✓ Branch 1 taken 72183 times.
✓ Branch 2 taken 72183 times.
✓ Branch 3 taken 11559088 times.
✓ Branch 4 taken 71496 times.
✓ Branch 5 taken 687 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11559775 times.
11631271 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
14443 71496 btnwpn=-1;
14444 11631271 }
14445
14446
2/2
✓ Branch 0 taken 4406377 times.
✓ Branch 1 taken 8796342 times.
13202719 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
14447
11/12
✓ Branch 0 taken 12369807 times.
✓ Branch 1 taken 832912 times.
✓ Branch 2 taken 11805694 times.
✓ Branch 3 taken 564113 times.
✓ Branch 4 taken 8210229 times.
✓ Branch 5 taken 3595465 times.
✓ Branch 6 taken 8150799 times.
✓ Branch 7 taken 59430 times.
✓ Branch 8 taken 86530 times.
✓ Branch 9 taken 8064269 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 86530 times.
13202719 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
14448 {
14449
2/2
✓ Branch 0 taken 3645 times.
✓ Branch 1 taken 82885 times.
86530 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
14450
5/6
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 86513 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
86530 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
14451 {
14452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 86513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
86513 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
14453 {
14454 paymagiccost(attackid,true);
14455 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
14456 }
14457 86513 SetAttack();
14458 86513 attack=wSword;
14459
14460 86513 attackclk=0;
14461
2/2
✓ Branch 0 taken 3628 times.
✓ Branch 1 taken 82885 times.
86513 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
14462
14463
7/10
✓ Branch 0 taken 86513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 85989 times.
✓ Branch 4 taken 524 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 517 times.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
86513 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14464 {
14465
1/2
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
517 if(!checkmagiccost(dowpn))
14466 {
14467 item_error();
14468 }
14469 else
14470 {
14471 //clear the item script stack for a new script
14472 517 int i = dowpn;
14473 517 FFCore.reset_script_engine_data(ScriptType::Item, i);
14474 517 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14475 517 did_scripta=true;
14476 }
14477 517 }
14478 86513 }
14479 else
14480 {
14481 17 item_error();
14482 }
14483 86530 }
14484 else
14485 {
14486 13116189 did_scripta=false;
14487 }
14488
14489
6/10
✓ Branch 0 taken 13052588 times.
✓ Branch 1 taken 150131 times.
✓ Branch 2 taken 13052588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13052588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13052588 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 13052588 times.
13202719 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
14490 {
14491
3/4
✓ Branch 0 taken 2303034 times.
✓ Branch 1 taken 10749554 times.
✓ Branch 2 taken 2303034 times.
✗ Branch 3 not taken.
13052588 if(DrunkUp() && canSideviewLadder())
14492 {
14493 setOnSideviewLadder(true);
14494 }
14495
3/4
✓ Branch 0 taken 1995410 times.
✓ Branch 1 taken 11057178 times.
✓ Branch 2 taken 1995410 times.
✗ Branch 3 not taken.
13052588 else if(DrunkDown() && canSideviewLadder(true))
14496 {
14497 y+=1;
14498 old_y += 1;
14499 setOnSideviewLadder(true);
14500 }
14501 13052588 }
14502
14503 13202719 int32_t wx=x;
14504 13202719 int32_t wy=y;
14505
3/6
✓ Branch 0 taken 9074082 times.
✓ Branch 1 taken 4128637 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13202719 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13202719 if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14506 {
14507 if((xoff==0)||diagonalMovement)
14508 {
14509 if(DrunkUp()) dir=up;
14510 if(DrunkDown()) dir=down;
14511 }
14512
14513 if((yoff==0)||diagonalMovement)
14514 {
14515 if(DrunkLeft()) dir=left;
14516 if(DrunkRight()) dir=right;
14517 }
14518 }
14519
14520
5/5
✓ Branch 0 taken 23246 times.
✓ Branch 1 taken 3105435 times.
✓ Branch 2 taken 2662005 times.
✓ Branch 3 taken 3569307 times.
✓ Branch 4 taken 3842726 times.
13202719 switch(dir)
14521 {
14522 case up:
14523 3105435 wy-=16;
14524 3105435 break;
14525
14526 case down:
14527 2662005 wy+=16;
14528 2662005 break;
14529
14530 case left:
14531 3569307 wx-=16;
14532 3569307 break;
14533
14534 case right:
14535 3842726 wx+=16;
14536 3842726 break;
14537 }
14538
14539 13202719 do_lens();
14540
14541 13202719 WalkflagInfo info;
14542
14543 13202719 bool no_jinx = true;
14544
2/2
✓ Branch 0 taken 13201279 times.
✓ Branch 1 taken 1440 times.
13202719 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
14545
2/2
✓ Branch 0 taken 23246 times.
✓ Branch 1 taken 13179473 times.
13202719 if(liftonly)
14546 {
14547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23246 if(replay_version_check(38) && btnwpn > -1)
14548 {
14549 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14550 no_jinx = checkitem_jinx(itmid);
14551 if(no_jinx)
14552 startwpn(itmid);
14553 directWpn = olddirectwpn;
14554 }
14555 23246 }
14556
6/8
✓ Branch 0 taken 12369807 times.
✓ Branch 1 taken 809666 times.
✓ Branch 2 taken 28457 times.
✓ Branch 3 taken 12341350 times.
✓ Branch 4 taken 28457 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28457 times.
13179473 else if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
14557 {
14558 28457 bool paidmagic = false;
14559
5/8
✓ Branch 0 taken 26672 times.
✓ Branch 1 taken 1785 times.
✓ Branch 2 taken 1785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1785 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1785 times.
28457 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
14560 {
14561
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
14562 1785 no_jinx = checkitem_jinx(attackid);
14563
4/8
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1784 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1784 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1785 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14564 {
14565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1784 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
14566 paymagiccost(attackid,true);
14567 misc_internal_hero_flags |= LF_PAID_WAND_COST;
14568 }
14569 1784 SetAttack();
14570 1784 attack=wWand;
14571 1784 attackclk=0;
14572 1784 }
14573 else
14574 {
14575 1 item_error();
14576 }
14577 1785 }
14578
4/6
✓ Branch 0 taken 2257 times.
✓ Branch 1 taken 24415 times.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
28929 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
14579
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
2257 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
14580 {
14581 2257 no_jinx = checkitem_jinx(dowpn);
14582
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
2257 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
14583 {
14584 item_error();
14585 }
14586 else
14587 {
14588 2257 paymagiccost(dowpn);
14589 2257 paidmagic = true;
14590 2257 SetAttack();
14591 2257 attack=wHammer;
14592
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
14593 2257 attackclk=0;
14594 }
14595 2257 }
14596
4/6
✓ Branch 0 taken 1832 times.
✓ Branch 1 taken 22583 times.
✓ Branch 2 taken 1832 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1832 times.
26247 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
14597
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✓ Branch 2 taken 1832 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1832 times.
1832 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
14598 {
14599 //checkbunny handled where magic cost is paid
14600
1/2
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
1832 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
14601 1832 no_jinx = checkitem_jinx(attackid);
14602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
1832 if(no_jinx)
14603 {
14604 1832 SetAttack();
14605 1832 attack=wFire;
14606 1832 attackclk=0;
14607 1832 }
14608 1832 }
14609
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22579 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
22587 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
14610
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
14611 {
14612
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
14613 4 no_jinx = checkitem_jinx(attackid);
14614
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14615 {
14616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
14617 paymagiccost(attackid,true);
14618 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
14619 }
14620 4 SetAttack();
14621 4 attack=wCByrna;
14622 4 attackclk=0;
14623 4 }
14624 else
14625 {
14626 item_error();
14627 }
14628 4 }
14629
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22579 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
14630 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
14631 {
14632 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
14633 no_jinx = checkitem_jinx(attackid);
14634 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
14635 {
14636 paymagiccost(attackid);
14637 SetAttack();
14638 attack = wBugNet;
14639 attackclk = 0;
14640 sfx(itemsbuf[attackid].usesound);
14641 }
14642 else
14643 {
14644 item_error();
14645 }
14646 }
14647 else
14648 {
14649
1/2
✓ Branch 0 taken 22579 times.
✗ Branch 1 not taken.
22579 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14650 22579 no_jinx = checkitem_jinx(itmid);
14651
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 22528 times.
22579 if(no_jinx)
14652 {
14653 22528 paidmagic = startwpn(itmid);
14654
14655
2/2
✓ Branch 0 taken 19443 times.
✓ Branch 1 taken 3085 times.
22528 if(paidmagic)
14656 {
14657
6/10
✓ Branch 0 taken 19423 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 19423 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19423 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 19423 times.
19443 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
14658 {
14659 ;
14660 20 }
14661 else
14662 {
14663 19423 SetAttack();
14664 19423 attackclk=0;
14665 19423 attack=none;
14666
14667
2/2
✓ Branch 0 taken 5936 times.
✓ Branch 1 taken 13487 times.
19423 if(btnwpn==itype_brang)
14668 {
14669 13487 attack=wBrang;
14670 13487 }
14671 }
14672 19443 }
14673 else
14674 {
14675 // Weapon not started: directWpn should be reset to prev. value.
14676 3085 directWpn = olddirectwpn;
14677 }
14678 22528 }
14679 }
14680
14681
8/12
✓ Branch 0 taken 28457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28405 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 1276 times.
✓ Branch 5 taken 27129 times.
✓ Branch 6 taken 1210 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1210 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28457 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14682 {
14683
3/4
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1210 times.
1210 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
14684 {
14685 item_error();
14686 }
14687 else
14688 {
14689 // Only charge for magic if item's magic cost wasn't already charged
14690 // for the item's main use.
14691
4/4
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1199 times.
1210 if(!paidmagic && attack!=wWand)
14692 1199 paymagiccost(dowpn);
14693 //clear the item script stack for a new script
14694 1210 int i = dowpn;
14695 1210 FFCore.reset_script_engine_data(ScriptType::Item, i);
14696 1210 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14697 1210 did_scriptb=true;
14698 }
14699 1210 }
14700
14701
8/12
✓ Branch 0 taken 28405 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 28385 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 28385 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28385 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28385 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28385 times.
28457 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
14702 {
14703 20 return;
14704 }
14705
2/2
✓ Branch 0 taken 28385 times.
✓ Branch 1 taken 52 times.
28437 if(!no_jinx)
14706 52 did_scriptb = false;
14707 28437 }
14708 else
14709 {
14710 13151016 did_scriptb=false;
14711 }
14712
14713
6/6
✓ Branch 0 taken 11571100 times.
✓ Branch 1 taken 1585107 times.
✓ Branch 2 taken 11447816 times.
✓ Branch 3 taken 123284 times.
✓ Branch 4 taken 23246 times.
✓ Branch 5 taken 11456230 times.
13202699 if(attackclk || action==attacking || action==sideswimattacking)
14714 {
14715
14716
4/8
✓ Branch 0 taken 123284 times.
✓ Branch 1 taken 1608353 times.
✓ Branch 2 taken 123284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 123284 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1731637 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14717 {
14718 if((xoff==0)||diagonalMovement)
14719 {
14720 if(DrunkUp()) dir=up;
14721 if(DrunkDown()) dir=down;
14722 }
14723
14724 if((yoff==0)||diagonalMovement)
14725 {
14726 if(DrunkLeft()) dir=left;
14727 if(DrunkRight()) dir=right;
14728 }
14729 }
14730
14731 1731637 bool attacked = doattack();
14732
14733 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14734
10/12
✓ Branch 0 taken 1728492 times.
✓ Branch 1 taken 3145 times.
✓ Branch 2 taken 1245326 times.
✓ Branch 3 taken 483166 times.
✓ Branch 4 taken 266041 times.
✓ Branch 5 taken 979285 times.
✓ Branch 6 taken 230392 times.
✓ Branch 7 taken 35649 times.
✓ Branch 8 taken 230392 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 230392 times.
1731637 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14735 {
14736
4/4
✓ Branch 0 taken 111335 times.
✓ Branch 1 taken 119057 times.
✓ Branch 2 taken 38493 times.
✓ Branch 3 taken 72842 times.
230392 if((xoff==0)||diagonalMovement)
14737 {
14738
2/2
✓ Branch 0 taken 141117 times.
✓ Branch 1 taken 16433 times.
157550 if(DrunkUp()) dir=up;
14739
14740
2/2
✓ Branch 0 taken 138033 times.
✓ Branch 1 taken 19517 times.
157550 if(DrunkDown()) dir=down;
14741 157550 }
14742
14743
4/4
✓ Branch 0 taken 88085 times.
✓ Branch 1 taken 142307 times.
✓ Branch 2 taken 35934 times.
✓ Branch 3 taken 52151 times.
230392 if((yoff==0)||diagonalMovement)
14744 {
14745
2/2
✓ Branch 0 taken 152737 times.
✓ Branch 1 taken 25504 times.
178241 if(DrunkLeft()) dir=left;
14746
14747
2/2
✓ Branch 0 taken 151833 times.
✓ Branch 1 taken 26408 times.
178241 if(DrunkRight()) dir=right;
14748 178241 }
14749 230392 }
14750
14751
9/10
✓ Branch 0 taken 1615480 times.
✓ Branch 1 taken 116157 times.
✓ Branch 2 taken 1574494 times.
✓ Branch 3 taken 40986 times.
✓ Branch 4 taken 1574059 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 1568260 times.
✓ Branch 7 taken 5799 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1568260 times.
1731637 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14752 {
14753 1568260 return;
14754 }
14755
2/2
✓ Branch 0 taken 47220 times.
✓ Branch 1 taken 116157 times.
163377 else if(!attacked)
14756 {
14757 // Spin attack - change direction
14758
3/4
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 115492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
116157 if(spins>1 && attack != wHammer)
14759 {
14760 665 spins--;
14761
14762
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 45 times.
665 if(spins%5==0)
14763 {
14764
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14765 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14766 45 }
14767 665 attackclk=1;
14768
14769
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 166 times.
✓ Branch 4 taken 166 times.
665 switch(dir)
14770 {
14771 case up:
14772 167 dir=left;
14773 167 break;
14774
14775 case right:
14776 166 dir=up;
14777 166 break;
14778
14779 case down:
14780 166 dir=right;
14781 166 break;
14782
14783 case left:
14784 166 dir=down;
14785 166 break;
14786 }
14787
14788 665 return;
14789 }
14790 else
14791 {
14792 115492 spins=0;
14793 }
14794
14795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115492 times.
115492 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14796 115492 else {action=none; FFCore.setHeroAction(none);}
14797 115492 attackclk=0;
14798 115492 charging=0;
14799 115492 }
14800 162712 }
14801
14802
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 11618880 times.
11618942 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14803 62 return;
14804
14805
2/2
✓ Branch 0 taken 4370360 times.
✓ Branch 1 taken 7248520 times.
11618880 if(action==walking) //still walking
14806 {
14807
9/10
✓ Branch 0 taken 5330346 times.
✓ Branch 1 taken 1918174 times.
✓ Branch 2 taken 3714796 times.
✓ Branch 3 taken 1615550 times.
✓ Branch 4 taken 1957225 times.
✓ Branch 5 taken 1757571 times.
✓ Branch 6 taken 80540 times.
✓ Branch 7 taken 1876685 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 80540 times.
7248520 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14808 {
14809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80540 times.
80540 if(attackclk>0) SetAttack();
14810 80540 else {action = none; FFCore.setHeroAction(none);}
14811 80540 hero_count=-1;
14812 80540 return;
14813 }
14814
14815 7167980 autostep=false;
14816
14817
4/6
✓ Branch 0 taken 4949766 times.
✓ Branch 1 taken 2218214 times.
✓ Branch 2 taken 4949766 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4949766 times.
7167980 if(!(diagonalMovement || NO_GRIDLOCK))
14818 {
14819
2/4
✓ Branch 0 taken 4949766 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4949766 times.
4949766 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
14820 {
14821 if(dir==up&&yoff)
14822 {
14823 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
14824 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
14825 execute(info);
14826
14827 if(!info.isUnwalkable())
14828 {
14829 moveOld2(up);
14830 }
14831 else
14832 {
14833 action=none; FFCore.setHeroAction(none);
14834 }
14835
14836 return;
14837 }
14838
14839 if(dir==down&&yoff)
14840 {
14841 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
14842 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
14843 execute(info);
14844
14845 if(!info.isUnwalkable())
14846 {
14847 moveOld2(down);
14848 }
14849 else
14850 {
14851 action=none; FFCore.setHeroAction(none);
14852 }
14853
14854 return;
14855 }
14856
14857 if(dir==left&&xoff)
14858 {
14859 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
14860 execute(info);
14861
14862 if(!info.isUnwalkable())
14863 {
14864 moveOld2(left);
14865 }
14866 else
14867 {
14868 action=none; FFCore.setHeroAction(none);
14869 }
14870
14871 return;
14872 }
14873
14874 if(dir==right&&xoff)
14875 {
14876 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
14877 execute(info);
14878
14879 if(!info.isUnwalkable())
14880 {
14881 moveOld2(right);
14882 }
14883 else
14884 {
14885 action=none; FFCore.setHeroAction(none);
14886 }
14887
14888 return;
14889 }
14890 }
14891 else
14892 {
14893
4/4
✓ Branch 0 taken 1152672 times.
✓ Branch 1 taken 3797094 times.
✓ Branch 2 taken 188796 times.
✓ Branch 3 taken 963876 times.
4949766 if(dir==up&&yoff)
14894 {
14895 963876 while(true)
14896 {
14897 963878 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
14898 963878 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
14899 963878 execute(info);
14900
14901
2/2
✓ Branch 0 taken 5173 times.
✓ Branch 1 taken 958705 times.
963878 if(!info.isUnwalkable())
14902 {
14903 958705 hero_newstep = temp_step;
14904 958705 x = temp_x;
14905 958705 y = temp_y;
14906 958705 moveOld2(up);
14907 958705 return;
14908 }
14909 //Could not move, try moving less
14910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
5173 if(temp_y != int32_t(temp_y))
14911 {
14912 temp_y = floor((double)temp_y);
14913 continue;
14914 }
14915
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5171 times.
5173 else if(temp_step > 1)
14916 {
14917
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_step != int32_t(temp_step)) //floor
14918 2 temp_step = floor((double)temp_step);
14919 else --temp_step;
14920 2 continue;
14921 }
14922 else //Can't move less, stop moving
14923 {
14924 5171 action=none; FFCore.setHeroAction(none);
14925 }
14926 5171 return;
14927 }
14928 }
14929
14930
4/4
✓ Branch 0 taken 945269 times.
✓ Branch 1 taken 3040621 times.
✓ Branch 2 taken 156271 times.
✓ Branch 3 taken 788998 times.
3985890 if(dir==down&&yoff)
14931 {
14932 788998 while(true)
14933 {
14934 789052 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14935 789052 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14936 789052 execute(info);
14937
14938
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 784597 times.
789052 if(!info.isUnwalkable())
14939 {
14940 784597 hero_newstep = temp_step;
14941 784597 x = temp_x;
14942 784597 y = temp_y;
14943 784597 moveOld2(down);
14944 784597 return;
14945 }
14946 //Could not move, try moving less
14947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4455 times.
4455 if(temp_y != int32_t(temp_y))
14948 {
14949 temp_y = floor((double)temp_y);
14950 continue;
14951 }
14952
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 4401 times.
4455 else if(temp_step > 1)
14953 {
14954
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(temp_step != int32_t(temp_step)) //floor
14955 54 temp_step = floor((double)temp_step);
14956 else --temp_step;
14957 54 continue;
14958 }
14959 else //Can't move less, stop moving
14960 {
14961 4401 action=none; FFCore.setHeroAction(none);
14962 }
14963 4401 return;
14964 }
14965 }
14966
14967
4/4
✓ Branch 0 taken 1387611 times.
✓ Branch 1 taken 1809281 times.
✓ Branch 2 taken 232515 times.
✓ Branch 3 taken 1155096 times.
3196892 if(dir==left&&xoff)
14968 {
14969 1155096 while(true)
14970 {
14971 1155096 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14972 1155096 execute(info);
14973
14974
2/2
✓ Branch 0 taken 5165 times.
✓ Branch 1 taken 1149931 times.
1155096 if(!info.isUnwalkable())
14975 {
14976 1149931 hero_newstep = temp_step;
14977 1149931 x = temp_x;
14978 1149931 y = temp_y;
14979 1149931 moveOld2(left);
14980 1149931 return;
14981 }
14982 //Could not move, try moving less
14983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 if(temp_x != int32_t(temp_x))
14984 {
14985 temp_x = floor((double)temp_x);
14986 continue;
14987 }
14988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 else if(temp_step > 1)
14989 {
14990 if(temp_step != int32_t(temp_step)) //floor
14991 temp_step = floor((double)temp_step);
14992 else --temp_step;
14993 continue;
14994 }
14995 else //Can't move less, stop moving
14996 {
14997 5165 action=none; FFCore.setHeroAction(none);
14998 }
14999 5165 return;
15000 }
15001 }
15002
15003
4/4
✓ Branch 0 taken 1464214 times.
✓ Branch 1 taken 577582 times.
✓ Branch 2 taken 245328 times.
✓ Branch 3 taken 1218886 times.
2041796 if(dir==right&&xoff)
15004 {
15005 1218886 while(true)
15006 {
15007 1218949 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15008 1218949 execute(info);
15009
15010
2/2
✓ Branch 0 taken 5828 times.
✓ Branch 1 taken 1213121 times.
1218949 if(!info.isUnwalkable())
15011 {
15012 1213121 hero_newstep = temp_step;
15013 1213121 x = temp_x;
15014 1213121 y = temp_y;
15015 1213121 moveOld2(right);
15016 1213121 return;
15017 }
15018 //Could not move, try moving less
15019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5828 times.
5828 if(temp_x != int32_t(temp_x))
15020 {
15021 temp_x = floor((double)temp_x);
15022 continue;
15023 }
15024
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 5765 times.
5828 else if(temp_step > 1)
15025 {
15026
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(temp_step != int32_t(temp_step)) //floor
15027 63 temp_step = floor((double)temp_step);
15028 else --temp_step;
15029 63 continue;
15030 }
15031 else //Can't move less, stop moving
15032 {
15033 5765 action=none; FFCore.setHeroAction(none);
15034 }
15035 5765 return;
15036 }
15037 }
15038 }
15039 822910 }
15040
15041 3041124 } // endif (action==walking)
15042
15043
16/24
✓ Branch 0 taken 7276185 times.
✓ Branch 1 taken 135299 times.
✓ Branch 2 taken 7276185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7276185 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7276185 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7276185 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7276185 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7276185 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7276185 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7276185 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 7235199 times.
✓ Branch 19 taken 40986 times.
✓ Branch 20 taken 7234764 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 109495 times.
✓ Branch 23 taken 7125269 times.
7411484 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
15044 {
15045 7125269 action=none; FFCore.setHeroAction(none);
15046 7125269 }
15047
15048
2/2
✓ Branch 0 taken 3632396 times.
✓ Branch 1 taken 3779088 times.
7411484 if(diagonalMovement)
15049 {
15050
5/5
✓ Branch 0 taken 1170411 times.
✓ Branch 1 taken 532104 times.
✓ Branch 2 taken 453865 times.
✓ Branch 3 taken 704485 times.
✓ Branch 4 taken 771531 times.
3632396 switch(holddir)
15051 {
15052 case up:
15053
2/2
✓ Branch 0 taken 515078 times.
✓ Branch 1 taken 17026 times.
532104 if(!Up())
15054 {
15055 17026 holddir=-1;
15056 17026 }
15057
15058 532104 break;
15059
15060 case down:
15061
2/2
✓ Branch 0 taken 438723 times.
✓ Branch 1 taken 15142 times.
453865 if(!Down())
15062 {
15063 15142 holddir=-1;
15064 15142 }
15065
15066 453865 break;
15067
15068 case left:
15069
2/2
✓ Branch 0 taken 684031 times.
✓ Branch 1 taken 20454 times.
704485 if(!Left())
15070 {
15071 20454 holddir=-1;
15072 20454 }
15073
15074 704485 break;
15075
15076 case right:
15077
2/2
✓ Branch 0 taken 750256 times.
✓ Branch 1 taken 21275 times.
771531 if(!Right())
15078 {
15079 21275 holddir=-1;
15080 21275 }
15081
15082 771531 break;
15083
15084 default:
15085 1170411 break;
15086 } //end switch
15087
15088
4/4
✓ Branch 0 taken 3062849 times.
✓ Branch 1 taken 569547 times.
✓ Branch 2 taken 38588 times.
✓ Branch 3 taken 3101437 times.
3632396 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
15089 {
15090 608135 walkable = false;
15091
6/6
✓ Branch 0 taken 102006 times.
✓ Branch 1 taken 459127 times.
✓ Branch 2 taken 98793 times.
✓ Branch 3 taken 3213 times.
✓ Branch 4 taken 24447 times.
✓ Branch 5 taken 74346 times.
608135 if(DrunkUp()&&(holddir==-1||holddir==up))
15092 {
15093
5/8
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 74469 times.
✓ Branch 2 taken 3057 times.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3090 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
77559 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
15094 {
15095 }
15096 else
15097 {
15098
5/10
✓ Branch 0 taken 76595 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 76595 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76595 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 76595 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
77559 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15099 {
15100 76595 dir=up;
15101 76595 }
15102
15103 77559 holddir=up;
15104
15105
4/4
✓ Branch 0 taken 9850 times.
✓ Branch 1 taken 67709 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9848 times.
77559 if(DrunkRight()&&shiftdir!=left)
15106 {
15107 9848 shiftdir=right;
15108
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9848 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15109
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9848 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15110 9848 }
15111
4/4
✓ Branch 0 taken 9049 times.
✓ Branch 1 taken 58662 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9040 times.
67711 else if(DrunkLeft()&&shiftdir!=right)
15112 {
15113 9040 shiftdir=left;
15114
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9040 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9040 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9040 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9040 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15116 9040 }
15117 else
15118 {
15119 58671 shiftdir=-1;
15120 }
15121
15122 //walkable if Ladder can be placed or is already placed vertically
15123
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 77559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
77559 if(isSideViewHero() && !toogam && !((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15124 {
15125 walkable=false;
15126 }
15127 else
15128 {
15129
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 77559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 77555 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
77559 if ((get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) justmoved = 2; //Prevent the slope-snap code from running
15130 77559 do
15131 {
15132 89741 zfix ty = y - hero_newstep;
15133 179482 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15134 89741 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15135
15136
4/4
✓ Branch 0 taken 307 times.
✓ Branch 1 taken 89434 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 287 times.
89741 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15137 {
15138 287 info = info || walkflag(x, 0_zf, 2, up);
15139 287 info = info || walkflag(x+15, 0_zf, 1, up);
15140 287 }
15141 89741 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15142
15143 89741 execute(info);
15144
15145
2/2
✓ Branch 0 taken 23217 times.
✓ Branch 1 taken 66524 times.
89741 if(info.isUnwalkable())
15146 {
15147
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 22070 times.
23217 if(y != y.getInt())
15148 {
15149 1147 y.doRound();
15150 1147 }
15151
2/2
✓ Branch 0 taken 11035 times.
✓ Branch 1 taken 11035 times.
22070 else if(hero_newstep > 1)
15152 {
15153
1/2
✓ Branch 0 taken 11035 times.
✗ Branch 1 not taken.
11035 if(hero_newstep != int32_t(hero_newstep)) //floor
15154 11035 hero_newstep = floor((double)hero_newstep);
15155 else --hero_newstep;
15156 11035 }
15157 else
15158 11035 break;
15159 12182 }
15160 66524 else walkable = true;
15161
2/2
✓ Branch 0 taken 12182 times.
✓ Branch 1 taken 66524 times.
78706 }
15162 78706 while(!walkable);
15163 }
15164
15165 77559 int32_t s=shiftdir;
15166
15167
5/6
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 74469 times.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3090 times.
✗ Branch 5 not taken.
77559 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
15168 {
15169 shiftdir=-1;
15170 }
15171 else
15172 {
15173
2/2
✓ Branch 0 taken 9040 times.
✓ Branch 1 taken 68519 times.
77559 if(s==left)
15174 {
15175 9040 do
15176 {
15177 10486 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15178
15179 10486 execute(info);
15180
15181
2/2
✓ Branch 0 taken 2765 times.
✓ Branch 1 taken 7721 times.
10486 if(info.isUnwalkable())
15182 {
15183
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 2638 times.
2765 if(x != x.getInt())
15184 {
15185 127 x.doRound();
15186 127 }
15187
2/2
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
2638 else if(hero_newstep_diag > 1)
15188 {
15189
1/2
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
1319 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15190 1319 hero_newstep_diag.doFloor();
15191 else --hero_newstep_diag;
15192 1319 }
15193 else
15194 1319 shiftdir = -1;
15195 2765 }
15196
2/2
✓ Branch 0 taken 6389 times.
✓ Branch 1 taken 1332 times.
7721 else if(walkable)
15197 {
15198 6389 do
15199 {
15200 6418 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
15201 6418 execute(info);
15202
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 6372 times.
6418 if(info.isUnwalkable())
15203 {
15204
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34 times.
46 if(x != x.getInt())
15205 {
15206 12 x.doRound();
15207 12 }
15208
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 else if(hero_newstep_diag > 1)
15209 {
15210
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15211 17 hero_newstep_diag.doFloor();
15212 else --hero_newstep_diag;
15213 17 }
15214 else
15215 17 shiftdir = -1;
15216 46 }
15217 6372 else break;
15218
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 17 times.
46 }
15219 46 while(shiftdir != -1);
15220 6389 break;
15221 }
15222 1332 else break;
15223
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 1319 times.
2765 }
15224 2765 while(shiftdir != -1);
15225 9040 }
15226
2/2
✓ Branch 0 taken 58671 times.
✓ Branch 1 taken 9848 times.
68519 else if(s==right)
15227 {
15228 9848 do
15229 {
15230 11460 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15231
15232 11460 execute(info);
15233
15234
2/2
✓ Branch 0 taken 3070 times.
✓ Branch 1 taken 8390 times.
11460 if(info.isUnwalkable())
15235 {
15236
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2942 times.
3070 if(x != x.getInt())
15237 {
15238 128 x.doRound();
15239 128 }
15240
2/2
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 1458 times.
2942 else if(hero_newstep_diag > 1)
15241 {
15242
1/2
✓ Branch 0 taken 1484 times.
✗ Branch 1 not taken.
1484 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15243 1484 hero_newstep_diag.doFloor();
15244 else --hero_newstep_diag;
15245 1484 }
15246 else
15247 1458 shiftdir = -1;
15248 3070 }
15249
2/2
✓ Branch 0 taken 7069 times.
✓ Branch 1 taken 1321 times.
8390 else if(walkable)
15250 {
15251 7069 do
15252 {
15253 7093 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
15254 7093 execute(info);
15255
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 7053 times.
7093 if(info.isUnwalkable())
15256 {
15257
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(x != x.getInt())
15258 {
15259 7 x.doRound();
15260 7 }
15261
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 17 times.
33 else if(hero_newstep_diag > 1)
15262 {
15263
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15264 17 hero_newstep_diag.doFloor();
15265 else --hero_newstep_diag;
15266 17 }
15267 else
15268 16 shiftdir = -1;
15269 40 }
15270 7053 else break;
15271
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 16 times.
40 }
15272 40 while(shiftdir != -1);
15273 7069 break;
15274 }
15275 1321 else break;
15276
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 1458 times.
3070 }
15277 3070 while(shiftdir != -1);
15278 9848 }
15279 }
15280
15281 77559 moveOld2(up);
15282 77559 shiftdir=s;
15283
15284
2/2
✓ Branch 0 taken 66524 times.
✓ Branch 1 taken 11035 times.
77559 if(!walkable)
15285 {
15286
2/2
✓ Branch 0 taken 3031 times.
✓ Branch 1 taken 8004 times.
11035 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15287 {
15288 8004 x = x.getInt();
15289 8004 y = y.getInt();
15290
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8004 times.
✓ Branch 2 taken 8004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6226 times.
✓ Branch 5 taken 1778 times.
✓ Branch 6 taken 532 times.
✓ Branch 7 taken 7472 times.
9782 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15291
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1778 times.
✓ Branch 4 taken 1115 times.
✓ Branch 5 taken 663 times.
1778 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15292
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
15293 {
15294
7/12
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 520 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 520 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 532 times.
532 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
15295 532 sprite::move((zfix)-1,(zfix)0);
15296 532 }
15297 else
15298 {
15299
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7472 times.
✓ Branch 4 taken 1246 times.
✓ Branch 5 taken 6226 times.
✓ Branch 6 taken 589 times.
✓ Branch 7 taken 6883 times.
13698 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15300
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6226 times.
✓ Branch 4 taken 5637 times.
✓ Branch 5 taken 589 times.
6226 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15301
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
589 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
15302 {
15303
7/12
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 582 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 582 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 582 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 589 times.
589 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
15304 589 sprite::move((zfix)1,(zfix)0);
15305 589 }
15306 else
15307 {
15308 6883 pushing=push+1;
15309 }
15310 }
15311 8004 }
15312 else
15313 {
15314 3031 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15315 }
15316 11035 }
15317
15318 77559 return;
15319 }
15320 }
15321
15322
6/6
✓ Branch 0 taken 98716 times.
✓ Branch 1 taken 384858 times.
✓ Branch 2 taken 95582 times.
✓ Branch 3 taken 3134 times.
✓ Branch 4 taken 73293 times.
✓ Branch 5 taken 22289 times.
483574 if(DrunkDown()&&(holddir==-1||holddir==down))
15323 {
15324
4/8
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 73740 times.
✓ Branch 2 taken 2687 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2687 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
76427 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
15325 {
15326 }
15327 else
15328 {
15329
5/10
✓ Branch 0 taken 76223 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 76223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76223 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 76223 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
76427 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15330 {
15331 76223 dir=down;
15332 76223 }
15333
15334 76427 holddir=down;
15335
15336
4/4
✓ Branch 0 taken 10699 times.
✓ Branch 1 taken 65728 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10691 times.
76427 if(DrunkRight()&&shiftdir!=left)
15337 {
15338 10691 shiftdir=right;
15339
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10691 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10691 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15340
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10691 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10691 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15341 10691 }
15342
4/4
✓ Branch 0 taken 11515 times.
✓ Branch 1 taken 54221 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 11503 times.
65736 else if(DrunkLeft()&&shiftdir!=right)
15343 {
15344 11503 shiftdir=left;
15345
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11503 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15346
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11503 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15347 11503 }
15348 else
15349 {
15350 54233 shiftdir=-1;
15351 }
15352
15353 //bool walkable;
15354
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 76427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
76427 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15355 {
15356 walkable=false;
15357 }
15358 else
15359 {
15360 76427 do
15361 {
15362 85872 info = walkflag(x,15+(y+hero_newstep),2,down);
15363
15364
2/2
✓ Branch 0 taken 52594 times.
✓ Branch 1 taken 33278 times.
85872 if(x.getFloor() & 7)
15365 52594 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
15366 else
15367 33278 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
15368
15369 85872 execute(info);
15370
15371
2/2
✓ Branch 0 taken 17827 times.
✓ Branch 1 taken 68045 times.
85872 if(info.isUnwalkable())
15372 {
15373
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 17002 times.
17827 if(y != y.getInt())
15374 {
15375 825 y.doRound();
15376 825 }
15377
2/2
✓ Branch 0 taken 8620 times.
✓ Branch 1 taken 8382 times.
17002 else if(hero_newstep > 1)
15378 {
15379
1/2
✓ Branch 0 taken 8620 times.
✗ Branch 1 not taken.
8620 if(hero_newstep != int32_t(hero_newstep)) //floor
15380 8620 hero_newstep = floor((double)hero_newstep);
15381 else --hero_newstep;
15382 8620 }
15383 else
15384 8382 break;
15385 9445 }
15386 68045 else walkable = true;
15387
2/2
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 68045 times.
77490 }
15388 77490 while(!walkable);
15389 }
15390
15391 76427 int32_t s=shiftdir;
15392
15393
5/6
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 73740 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2687 times.
✗ Branch 5 not taken.
76427 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM))
15394 {
15395 shiftdir=-1;
15396 }
15397 else
15398 {
15399
2/2
✓ Branch 0 taken 11503 times.
✓ Branch 1 taken 64924 times.
76427 if(s==left)
15400 {
15401 11503 do
15402 {
15403 13134 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15404
15405 13134 execute(info);
15406
15407
2/2
✓ Branch 0 taken 3070 times.
✓ Branch 1 taken 10064 times.
13134 if(info.isUnwalkable())
15408 {
15409
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2878 times.
3070 if(x != x.getInt())
15410 {
15411 192 x.doRound();
15412 192 }
15413
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 1439 times.
2878 else if(hero_newstep_diag > 1)
15414 {
15415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1439 times.
1439 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15416 1439 hero_newstep_diag.doFloor();
15417 else --hero_newstep_diag;
15418 1439 }
15419 else
15420 1439 shiftdir = -1;
15421 3070 }
15422
2/2
✓ Branch 0 taken 8469 times.
✓ Branch 1 taken 1595 times.
10064 else if(walkable)
15423 {
15424 8469 do
15425 {
15426 8511 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
15427 8511 execute(info);
15428
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8452 times.
8511 if(info.isUnwalkable())
15429 {
15430
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 34 times.
59 if(x != x.getInt())
15431 {
15432 25 x.doRound();
15433 25 }
15434
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 else if(hero_newstep_diag > 1)
15435 {
15436
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15437 17 hero_newstep_diag.doFloor();
15438 else --hero_newstep_diag;
15439 17 }
15440 else
15441 17 shiftdir = -1;
15442 59 }
15443 8452 else break;
15444
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 17 times.
59 }
15445 59 while(shiftdir != -1);
15446 8469 break;
15447 }
15448 1595 else break;
15449
2/2
✓ Branch 0 taken 1631 times.
✓ Branch 1 taken 1439 times.
3070 }
15450 3070 while(shiftdir != -1);
15451 11503 }
15452
2/2
✓ Branch 0 taken 54233 times.
✓ Branch 1 taken 10691 times.
64924 else if(s==right)
15453 {
15454 10691 do
15455 {
15456 12068 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15457
15458 12068 execute(info);
15459
15460
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 9422 times.
12068 if(info.isUnwalkable())
15461 {
15462
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 2548 times.
2646 if(x != x.getInt())
15463 {
15464 98 x.doRound();
15465 98 }
15466
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 1269 times.
2548 else if(hero_newstep_diag > 1)
15467 {
15468
1/2
✓ Branch 0 taken 1279 times.
✗ Branch 1 not taken.
1279 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15469 1279 hero_newstep_diag.doFloor();
15470 else --hero_newstep_diag;
15471 1279 }
15472 else
15473 1269 shiftdir = -1;
15474 2646 }
15475
2/2
✓ Branch 0 taken 7796 times.
✓ Branch 1 taken 1626 times.
9422 else if(walkable)
15476 {
15477 7796 do
15478 {
15479 7842 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
15480 7842 execute(info);
15481
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7767 times.
7842 if(info.isUnwalkable())
15482 {
15483
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 58 times.
75 if(x != x.getInt())
15484 {
15485 17 x.doRound();
15486 17 }
15487
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 29 times.
58 else if(hero_newstep_diag > 1)
15488 {
15489
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15490 29 hero_newstep_diag.doFloor();
15491 else --hero_newstep_diag;
15492 29 }
15493 else
15494 29 shiftdir = -1;
15495 75 }
15496 7767 else break;
15497
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
75 }
15498 75 while(shiftdir != -1);
15499 7796 break;
15500 }
15501 1626 else break;
15502
2/2
✓ Branch 0 taken 1377 times.
✓ Branch 1 taken 1269 times.
2646 }
15503 2646 while(shiftdir != -1);
15504 10691 }
15505 }
15506
15507 76427 moveOld2(down);
15508 76427 shiftdir=s;
15509
15510
2/2
✓ Branch 0 taken 68045 times.
✓ Branch 1 taken 8382 times.
76427 if(!walkable)
15511 {
15512
2/2
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 4900 times.
8382 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15513 {
15514 4900 x = x.getInt();
15515 4900 y = y.getInt();
15516
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3632 times.
✓ Branch 5 taken 1268 times.
✓ Branch 6 taken 515 times.
✓ Branch 7 taken 4385 times.
6168 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
15517
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1268 times.
✓ Branch 4 taken 706 times.
✓ Branch 5 taken 562 times.
1268 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
15518
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 562 times.
562 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
15519 {
15520
9/12
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 511 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 511 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 507 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 507 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 515 times.
515 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
15521 515 sprite::move((zfix)-1,(zfix)0);
15522 515 }
15523
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4385 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4385 times.
✓ Branch 4 taken 753 times.
✓ Branch 5 taken 3632 times.
✓ Branch 6 taken 513 times.
✓ Branch 7 taken 3872 times.
8017 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
15524
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
✓ Branch 4 taken 3119 times.
✓ Branch 5 taken 513 times.
3632 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
15525
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513 times.
513 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
15526 {
15527
7/12
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 507 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 507 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 507 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 513 times.
513 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
15528 513 sprite::move((zfix)1,(zfix)0);
15529 513 }
15530 else
15531 {
15532 3872 pushing=push+1;
15533 }
15534 4900 }
15535 else
15536 {
15537 3482 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15538 }
15539 8382 }
15540
15541 76427 return;
15542 }
15543 }
15544
15545
6/6
✓ Branch 0 taken 105626 times.
✓ Branch 1 taken 301521 times.
✓ Branch 2 taken 102124 times.
✓ Branch 3 taken 3502 times.
✓ Branch 4 taken 102023 times.
✓ Branch 5 taken 101 times.
407147 if(DrunkLeft()&&(holddir==-1||holddir==left))
15546 {
15547
5/8
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 102533 times.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2992 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
105525 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM) && !toogam)
15548 {
15549 }
15550 else
15551 {
15552
4/6
✓ Branch 0 taken 105126 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 105126 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 105126 times.
105525 if(charging==0 && spins==0 && action != sideswimattacking)
15553 {
15554 105126 dir=left;
15555 105126 }
15556 105525 sideswimdir = left;
15557
15558 105525 holddir=left;
15559
15560
4/4
✓ Branch 0 taken 12469 times.
✓ Branch 1 taken 93056 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12468 times.
105525 if(DrunkUp()&&shiftdir!=down)
15561 {
15562 12468 shiftdir=up;
15563 12468 }
15564
4/4
✓ Branch 0 taken 11444 times.
✓ Branch 1 taken 81613 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11442 times.
93057 else if(DrunkDown()&&shiftdir!=up)
15565 {
15566 11442 shiftdir=down;
15567 11442 }
15568 else
15569 {
15570 81615 shiftdir=-1;
15571 }
15572
15573 105525 do
15574 {
15575 116860 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
15576
15577 116860 info = info || walkflag(x-hero_newstep,y+15,1,left);
15578
15579 116860 execute(info);
15580
15581
2/2
✓ Branch 0 taken 21300 times.
✓ Branch 1 taken 95560 times.
116860 if(info.isUnwalkable())
15582 {
15583
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 19928 times.
21300 if(x != x.getInt())
15584 {
15585 1372 x.doRound();
15586 1372 }
15587
2/2
✓ Branch 0 taken 9963 times.
✓ Branch 1 taken 9965 times.
19928 else if(hero_newstep > 1)
15588 {
15589
1/2
✓ Branch 0 taken 9963 times.
✗ Branch 1 not taken.
9963 if(hero_newstep != int32_t(hero_newstep)) //floor
15590 9963 hero_newstep = floor((double)hero_newstep);
15591 else --hero_newstep;
15592 9963 }
15593 else
15594 9965 break;
15595 11335 }
15596 95560 else walkable = true;
15597
2/2
✓ Branch 0 taken 11335 times.
✓ Branch 1 taken 95560 times.
106895 }
15598 106895 while(!walkable);
15599
15600 105525 int32_t s=shiftdir;
15601
15602
10/14
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 102533 times.
✓ Branch 2 taken 2948 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 2992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 894 times.
✓ Branch 7 taken 104631 times.
✓ Branch 8 taken 894 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 894 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 894 times.
✗ Branch 13 not taken.
105525 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15603 {
15604 894 shiftdir=-1;
15605 894 }
15606 else
15607 {
15608
2/2
✓ Branch 0 taken 92163 times.
✓ Branch 1 taken 12468 times.
104631 if(s==up)
15609 {
15610 12468 do
15611 {
15612 14161 zfix ty = y - hero_newstep_diag;
15613 28322 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15614 14161 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15615
15616
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
14161 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15617 {
15618 7 info = info || walkflag(x, 0_zf, 2, up);
15619 7 info = info || walkflag(x+15, 0_zf, 1, up);
15620 7 }
15621 14161 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15622
15623 14161 execute(info);
15624
15625
2/2
✓ Branch 0 taken 3189 times.
✓ Branch 1 taken 10972 times.
14161 if(info.isUnwalkable())
15626 {
15627
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 2992 times.
3189 if(y != y.getInt())
15628 {
15629 197 y.doRound();
15630 197 }
15631
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 1496 times.
2992 else if(hero_newstep_diag > 1)
15632 {
15633
1/2
✓ Branch 0 taken 1496 times.
✗ Branch 1 not taken.
1496 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15634 1496 hero_newstep_diag.doFloor();
15635 else --hero_newstep_diag;
15636 1496 }
15637 else
15638 1496 shiftdir = -1;
15639 3189 }
15640
2/2
✓ Branch 0 taken 9302 times.
✓ Branch 1 taken 1670 times.
10972 else if(walkable)
15641 {
15642 9302 do
15643 {
15644 9361 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
15645 9361 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
15646
15647
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9361 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15648 {
15649 7 info = info || walkflag(tx, 0_zf, 1, up);
15650 7 info = info || walkflag(tx+15, 0_zf, 1, up);
15651 7 }
15652 9361 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15653
15654 9361 execute(info);
15655
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 9264 times.
9361 if(info.isUnwalkable())
15656 {
15657
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 76 times.
97 if(y != y.getInt())
15658 {
15659 21 y.doRound();
15660 21 }
15661
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 else if(hero_newstep_diag > 1)
15662 {
15663
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15664 38 hero_newstep_diag.doFloor();
15665 else --hero_newstep_diag;
15666 38 }
15667 else
15668 38 shiftdir = -1;
15669 97 }
15670 9264 else break;
15671
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 38 times.
97 }
15672 97 while(shiftdir != -1);
15673 9302 break;
15674 }
15675 1670 else break;
15676
2/2
✓ Branch 0 taken 1693 times.
✓ Branch 1 taken 1496 times.
3189 }
15677 3189 while(shiftdir != -1);
15678 12468 }
15679
2/2
✓ Branch 0 taken 80721 times.
✓ Branch 1 taken 11442 times.
92163 else if(s==down)
15680 {
15681 11442 do
15682 {
15683 13536 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15684
15685 13536 execute(info);
15686
15687
2/2
✓ Branch 0 taken 3941 times.
✓ Branch 1 taken 9595 times.
13536 if(info.isUnwalkable())
15688 {
15689
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3740 times.
3941 if(y != y.getInt())
15690 {
15691 201 y.doRound();
15692 201 }
15693
2/2
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 1847 times.
3740 else if(hero_newstep_diag > 1)
15694 {
15695
1/2
✓ Branch 0 taken 1893 times.
✗ Branch 1 not taken.
1893 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15696 1893 hero_newstep_diag.doFloor();
15697 else --hero_newstep_diag;
15698 1893 }
15699 else
15700 1847 shiftdir = -1;
15701 3941 }
15702
2/2
✓ Branch 0 taken 7952 times.
✓ Branch 1 taken 1643 times.
9595 else if(walkable)
15703 {
15704 7952 do
15705 {
15706 7970 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
15707 7970 execute(info);
15708
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 7938 times.
7970 if(info.isUnwalkable())
15709 {
15710
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
32 if(y != y.getInt())
15711 {
15712 4 y.doRound();
15713 4 }
15714
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 else if(hero_newstep_diag > 1)
15715 {
15716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15717 14 hero_newstep_diag.doFloor();
15718 else --hero_newstep_diag;
15719 14 }
15720 else
15721 14 shiftdir = -1;
15722 32 }
15723 7938 else break;
15724
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
32 }
15725 32 while(shiftdir != -1);
15726 7952 break;
15727 }
15728 1643 else break;
15729
2/2
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 1847 times.
3941 }
15730 3941 while(shiftdir != -1);
15731 11442 }
15732 }
15733
15734 105525 moveOld2(left);
15735 105525 shiftdir=s;
15736
15737
2/2
✓ Branch 0 taken 95560 times.
✓ Branch 1 taken 9965 times.
105525 if(!walkable)
15738 {
15739
2/2
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 6285 times.
9965 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15740 {
15741 6285 x = x.getInt();
15742 6285 y = y.getInt();
15743 6285 int32_t v1=bigHitbox?0:8;
15744 6285 int32_t v2=bigHitbox?8:12;
15745
15746
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6285 times.
✓ Branch 4 taken 5067 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 6129 times.
7503 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
15747
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1218 times.
✓ Branch 4 taken 597 times.
✓ Branch 5 taken 621 times.
1218 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
15748
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 621 times.
621 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
15749 {
15750
9/12
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 146 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 156 times.
156 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15751 156 sprite::move((zfix)0,(zfix)-1);
15752 156 }
15753
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6129 times.
✓ Branch 4 taken 1062 times.
✓ Branch 5 taken 5067 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 5934 times.
11196 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
15754
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5067 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5067 times.
✓ Branch 4 taken 4872 times.
✓ Branch 5 taken 195 times.
5067 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
15755
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 195 times.
195 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
15756 {
15757
7/12
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 194 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 194 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 194 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
195 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15758 195 sprite::move((zfix)0,(zfix)1);
15759 195 }
15760 else
15761 {
15762 5934 pushing=push+1;
15763 }
15764 6285 }
15765 else
15766 {
15767 3680 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15768
15769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3680 times.
3680 if(action!=swimming)
15770 {
15771 3680 }
15772 }
15773 9965 }
15774
15775 105525 return;
15776 }
15777 }
15778
15779
5/6
✓ Branch 0 taken 108312 times.
✓ Branch 1 taken 193310 times.
✓ Branch 2 taken 104710 times.
✓ Branch 3 taken 3602 times.
✓ Branch 4 taken 104710 times.
✗ Branch 5 not taken.
301622 if(DrunkRight()&&(holddir==-1||holddir==right))
15780 {
15781
5/8
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 104889 times.
✓ Branch 2 taken 3321 times.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3423 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
108312 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM) && !toogam)
15782 {
15783 }
15784 else
15785 {
15786
4/6
✓ Branch 0 taken 107610 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 107610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 107610 times.
108312 if(charging==0 && spins==0 && action != sideswimattacking)
15787 {
15788 107610 dir=right;
15789 107610 }
15790 108312 sideswimdir = right;
15791
15792 108312 holddir=right;
15793
15794
4/4
✓ Branch 0 taken 11938 times.
✓ Branch 1 taken 96374 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11937 times.
108312 if(DrunkUp()&&shiftdir!=down)
15795 {
15796 11937 shiftdir=up;
15797 11937 }
15798
4/4
✓ Branch 0 taken 10841 times.
✓ Branch 1 taken 85534 times.
✓ Branch 2 taken 10837 times.
✓ Branch 3 taken 4 times.
96375 else if(DrunkDown()&&shiftdir!=up)
15799 {
15800 10837 shiftdir=down;
15801 10837 }
15802 else
15803 {
15804 85538 shiftdir=-1;
15805 }
15806
15807 108312 do
15808 {
15809 119870 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
15810
15811 119870 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
15812
15813 119870 execute(info);
15814
15815
2/2
✓ Branch 0 taken 21932 times.
✓ Branch 1 taken 97938 times.
119870 if(info.isUnwalkable())
15816 {
15817
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 21145 times.
21932 if(x != x.getInt())
15818 {
15819 787 x.doRound();
15820 787 }
15821
2/2
✓ Branch 0 taken 10771 times.
✓ Branch 1 taken 10374 times.
21145 else if(hero_newstep > 1)
15822 {
15823
1/2
✓ Branch 0 taken 10771 times.
✗ Branch 1 not taken.
10771 if(hero_newstep != int32_t(hero_newstep)) //floor
15824 10771 hero_newstep = floor((double)hero_newstep);
15825 else --hero_newstep;
15826 10771 }
15827 else
15828 10374 break;
15829 11558 }
15830 97938 else walkable = true;
15831
2/2
✓ Branch 0 taken 11558 times.
✓ Branch 1 taken 97938 times.
109496 }
15832 109496 while(!walkable);
15833
15834 108312 int32_t s=shiftdir;
15835
15836
10/14
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 104889 times.
✓ Branch 2 taken 3373 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 3423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1560 times.
✓ Branch 7 taken 106752 times.
✓ Branch 8 taken 1560 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1560 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1560 times.
✗ Branch 13 not taken.
108312 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15837 {
15838 1560 shiftdir=-1;
15839 1560 }
15840 else
15841 {
15842
2/2
✓ Branch 0 taken 94815 times.
✓ Branch 1 taken 11937 times.
106752 if(s==up)
15843 {
15844 11937 do
15845 {
15846 13313 zfix ty = y - hero_newstep_diag;
15847 26626 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15848 13313 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15849
15850
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
13313 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15851 {
15852 7 info = info || walkflag(x, 0_zf, 2, up);
15853 7 info = info || walkflag(x+15, 0_zf, 1, up);
15854 7 }
15855 13313 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15856
15857 13313 execute(info);
15858
15859
2/2
✓ Branch 0 taken 2558 times.
✓ Branch 1 taken 10755 times.
13313 if(info.isUnwalkable())
15860 {
15861
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 2364 times.
2558 if(y != y.getInt())
15862 {
15863 194 y.doRound();
15864 194 }
15865
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 1182 times.
2364 else if(hero_newstep_diag > 1)
15866 {
15867
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15868 1182 hero_newstep_diag.doFloor();
15869 else --hero_newstep_diag;
15870 1182 }
15871 else
15872 1182 shiftdir = -1;
15873 2558 }
15874
2/2
✓ Branch 0 taken 9440 times.
✓ Branch 1 taken 1315 times.
10755 else if(walkable)
15875 {
15876 9440 do
15877 {
15878 9488 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
15879 9488 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
15880
15881
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
9488 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15882 {
15883 5 info = info || walkflag(tx, 0_zf, 1, up);
15884 5 info = info || walkflag(tx+15, 0_zf, 1, up);
15885 5 }
15886 9488 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15887 9488 execute(info);
15888
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 9413 times.
9488 if(info.isUnwalkable())
15889 {
15890
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 54 times.
75 if(y != y.getInt())
15891 {
15892 21 y.doRound();
15893 21 }
15894
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 else if(hero_newstep_diag > 1)
15895 {
15896
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15897 27 hero_newstep_diag.doFloor();
15898 else --hero_newstep_diag;
15899 27 }
15900 else
15901 27 shiftdir = -1;
15902 75 }
15903 9413 else break;
15904
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 27 times.
75 }
15905 75 while(shiftdir != -1);
15906 9440 break;
15907 }
15908 1315 else break;
15909
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 1182 times.
2558 }
15910 2558 while(shiftdir != -1);
15911 11937 }
15912
2/2
✓ Branch 0 taken 83978 times.
✓ Branch 1 taken 10837 times.
94815 else if(s==down)
15913 {
15914 10837 do
15915 {
15916 12652 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15917
15918 12652 execute(info);
15919
15920
2/2
✓ Branch 0 taken 3373 times.
✓ Branch 1 taken 9279 times.
12652 if(info.isUnwalkable())
15921 {
15922
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 3164 times.
3373 if(y != y.getInt())
15923 {
15924 209 y.doRound();
15925 209 }
15926
2/2
✓ Branch 0 taken 1558 times.
✓ Branch 1 taken 1606 times.
3164 else if(hero_newstep_diag > 1)
15927 {
15928
1/2
✓ Branch 0 taken 1606 times.
✗ Branch 1 not taken.
1606 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15929 1606 hero_newstep_diag.doFloor();
15930 else --hero_newstep_diag;
15931 1606 }
15932 else
15933 1558 shiftdir = -1;
15934 3373 }
15935
2/2
✓ Branch 0 taken 7880 times.
✓ Branch 1 taken 1399 times.
9279 else if(walkable)
15936 {
15937 7880 do
15938 {
15939 7913 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15940 7913 execute(info);
15941
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 7859 times.
7913 if(info.isUnwalkable())
15942 {
15943
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 44 times.
54 if(y != y.getInt())
15944 {
15945 10 y.doRound();
15946 10 }
15947
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 23 times.
44 else if(hero_newstep_diag > 1)
15948 {
15949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15950 23 hero_newstep_diag.doFloor();
15951 else --hero_newstep_diag;
15952 23 }
15953 else
15954 21 shiftdir = -1;
15955 54 }
15956 7859 else break;
15957
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21 times.
54 }
15958 54 while(shiftdir != -1);
15959 7880 break;
15960 }
15961 1399 else break;
15962
2/2
✓ Branch 0 taken 1815 times.
✓ Branch 1 taken 1558 times.
3373 }
15963 3373 while(shiftdir != -1);
15964 10837 }
15965 }
15966
15967 108312 moveOld2(right);
15968 108312 shiftdir=s;
15969
15970
2/2
✓ Branch 0 taken 97938 times.
✓ Branch 1 taken 10374 times.
108312 if(!walkable)
15971 {
15972
2/2
✓ Branch 0 taken 2939 times.
✓ Branch 1 taken 7435 times.
10374 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15973 {
15974 7435 x = x.getInt();
15975 7435 y = y.getInt();
15976 7435 int32_t v1=bigHitbox?0:8;
15977 7435 int32_t v2=bigHitbox?8:12;
15978
15979
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7435 times.
✓ Branch 2 taken 7435 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6276 times.
✓ Branch 5 taken 1159 times.
✓ Branch 6 taken 238 times.
✓ Branch 7 taken 7197 times.
8594 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
15980
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1159 times.
✓ Branch 4 taken 701 times.
✓ Branch 5 taken 458 times.
1159 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
15981
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 458 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 458 times.
458 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
15982 {
15983
7/12
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 231 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 231 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 231 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 238 times.
238 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15984 238 sprite::move((zfix)0,(zfix)-1);
15985 238 }
15986
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7197 times.
✓ Branch 4 taken 921 times.
✓ Branch 5 taken 6276 times.
✓ Branch 6 taken 254 times.
✓ Branch 7 taken 6943 times.
13473 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
15987
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6276 times.
✓ Branch 4 taken 6022 times.
✓ Branch 5 taken 254 times.
6276 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
15988
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 254 times.
254 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
15989 {
15990
9/12
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 253 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 250 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 254 times.
254 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15991 254 sprite::move((zfix)0,(zfix)1);
15992 254 }
15993 else
15994 {
15995 6943 pushing=push+1;
15996 6943 z3step=2;
15997 }
15998 7435 }
15999 else
16000 {
16001 2939 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16002
16003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2939 times.
2939 if(action!=swimming)
16004 {
16005 2939 }
16006 }
16007 10374 }
16008
16009 108312 return;
16010 }
16011 }
16012 193310 }
16013 else
16014 {
16015
6/6
✓ Branch 0 taken 605306 times.
✓ Branch 1 taken 2496131 times.
✓ Branch 2 taken 591459 times.
✓ Branch 3 taken 13847 times.
✓ Branch 4 taken 120553 times.
✓ Branch 5 taken 470906 times.
3101437 if(DrunkUp()&&(holddir==-1||holddir==up))
16016 {
16017
5/8
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 480850 times.
✓ Branch 2 taken 3899 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3903 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
484753 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16018 {
16019 }
16020 else
16021 {
16022
3/4
✓ Branch 0 taken 440629 times.
✓ Branch 1 taken 44124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440629 times.
484753 if(charging==0 && spins==0)
16023 {
16024 440629 dir=up;
16025 440629 }
16026
16027 484753 holddir=up;
16028
16029
4/4
✓ Branch 0 taken 64206 times.
✓ Branch 1 taken 340161 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 64096 times.
484753 if(DrunkRight()&&shiftdir!=left)
16030 {
16031 64096 shiftdir=right;
16032 64096 }
16033
4/4
✓ Branch 0 taken 52930 times.
✓ Branch 1 taken 287341 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 52850 times.
340271 else if(DrunkLeft()&&shiftdir!=right)
16034 {
16035 52850 shiftdir=left;
16036 52850 }
16037 else
16038 {
16039 287421 shiftdir=-1;
16040 }
16041
16042 //walkable if Ladder can be placed or is already placed vertically
16043
10/18
✓ Branch 0 taken 21030 times.
✓ Branch 1 taken 383337 times.
✓ Branch 2 taken 21030 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 21030 times.
✓ Branch 6 taken 21030 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 20899 times.
✓ Branch 11 taken 20899 times.
✓ Branch 12 taken 20899 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20899 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 20899 times.
404367 if(isSideViewHero() && !toogam && !(((replay_version_check(0, 23) || get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16044 {
16045 20899 walkable=false;
16046 20899 }
16047 else
16048 {
16049
7/8
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 367801 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 56678 times.
✓ Branch 4 taken 963 times.
✓ Branch 5 taken 423516 times.
✓ Branch 6 taken 963 times.
✗ Branch 7 not taken.
425266 if ((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) justmoved = 2;
16050 425266 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16051
16052
2/2
✓ Branch 0 taken 231559 times.
✓ Branch 1 taken 193707 times.
425266 if(x.getInt() & 7)
16053 231559 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16054 else
16055 193707 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16056
16057 425266 execute(info);
16058
16059
2/2
✓ Branch 0 taken 66936 times.
✓ Branch 1 taken 358330 times.
425266 if(info.isUnwalkable())
16060 {
16061
2/2
✓ Branch 0 taken 65594 times.
✓ Branch 1 taken 1342 times.
66936 if(z3step==2)
16062 {
16063 65594 z3step=1;
16064 65594 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16065
16066
2/2
✓ Branch 0 taken 28001 times.
✓ Branch 1 taken 37593 times.
65594 if(x.getInt()&7)
16067 37593 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16068 else
16069 28001 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16070
16071 65594 execute(info);
16072
16073
2/2
✓ Branch 0 taken 60487 times.
✓ Branch 1 taken 5107 times.
65594 if(info.isUnwalkable())
16074 {
16075 60487 walkable = false;
16076 60487 }
16077 else
16078 {
16079 5107 walkable=true;
16080 }
16081 65594 }
16082 else
16083 {
16084 1342 walkable=false;
16085 }
16086 66936 }
16087 else
16088 {
16089 358330 walkable = true;
16090 }
16091 }
16092
16093 446165 int32_t s=shiftdir;
16094
16095
5/6
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 442262 times.
✓ Branch 2 taken 3784 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 3903 times.
✗ Branch 5 not taken.
446165 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
16096 {
16097 shiftdir=-1;
16098 }
16099 else
16100 {
16101
2/2
✓ Branch 0 taken 52850 times.
✓ Branch 1 taken 393315 times.
446165 if(s==left)
16102 {
16103 52850 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
16104 52850 execute(info);
16105
16106
2/2
✓ Branch 0 taken 7278 times.
✓ Branch 1 taken 45572 times.
52850 if(info.isUnwalkable())
16107 {
16108 7278 shiftdir=-1;
16109 7278 }
16110
2/2
✓ Branch 0 taken 9498 times.
✓ Branch 1 taken 36074 times.
45572 else if(walkable)
16111 {
16112 36074 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
16113 36074 execute(info);
16114
2/2
✓ Branch 0 taken 35991 times.
✓ Branch 1 taken 83 times.
36074 if(info.isUnwalkable())
16115 {
16116 83 shiftdir=-1;
16117 83 }
16118 36074 }
16119 52850 }
16120
2/2
✓ Branch 0 taken 329219 times.
✓ Branch 1 taken 64096 times.
393315 else if(s==right)
16121 {
16122 64096 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16123 64096 execute(info);
16124
16125
2/2
✓ Branch 0 taken 9315 times.
✓ Branch 1 taken 54781 times.
64096 if(info.isUnwalkable())
16126 {
16127 9315 shiftdir=-1;
16128 9315 }
16129
2/2
✓ Branch 0 taken 11126 times.
✓ Branch 1 taken 43655 times.
54781 else if(walkable)
16130 {
16131 43655 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
16132 43655 execute(info);
16133
16134
2/2
✓ Branch 0 taken 43569 times.
✓ Branch 1 taken 86 times.
43655 if(info.isUnwalkable())
16135 {
16136 86 shiftdir=-1;
16137 86 }
16138 43655 }
16139 64096 }
16140 }
16141
16142 446165 moveOld2(up);
16143 446165 shiftdir=s;
16144
16145
2/2
✓ Branch 0 taken 363437 times.
✓ Branch 1 taken 82728 times.
446165 if(!walkable)
16146 {
16147
2/2
✓ Branch 0 taken 25064 times.
✓ Branch 1 taken 57664 times.
82728 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16148 {
16149
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 57664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57664 times.
✓ Branch 4 taken 29302 times.
✓ Branch 5 taken 28362 times.
✓ Branch 6 taken 2488 times.
✓ Branch 7 taken 55176 times.
86026 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16150
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28362 times.
✓ Branch 4 taken 5838 times.
✓ Branch 5 taken 22524 times.
28362 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16151
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22524 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22524 times.
22524 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16152 {
16153
9/12
✓ Branch 0 taken 2417 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 2417 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2417 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2389 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 2389 times.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2488 times.
2488 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16154 2488 sprite::move((zfix)-1,(zfix)0);
16155 2488 }
16156 else
16157 {
16158
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 55176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55176 times.
✓ Branch 4 taken 25874 times.
✓ Branch 5 taken 29302 times.
✓ Branch 6 taken 2472 times.
✓ Branch 7 taken 52704 times.
84478 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16159
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29302 times.
✓ Branch 4 taken 26830 times.
✓ Branch 5 taken 2472 times.
29302 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16160
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2472 times.
2472 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16161 {
16162
10/12
✓ Branch 0 taken 2383 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 2383 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2383 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2370 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 2370 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2470 times.
2472 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16163 2470 sprite::move((zfix)1,(zfix)0);
16164 2472 }
16165 else
16166 {
16167 52704 pushing=push+1;
16168 }
16169 }
16170
16171 57664 z3step=2;
16172 57664 }
16173 else
16174 {
16175 25064 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16176 25064 z3step=2;
16177 }
16178 82728 }
16179
16180 446165 return;
16181 }
16182 }
16183
16184
6/6
✓ Branch 0 taken 505248 times.
✓ Branch 1 taken 2111436 times.
✓ Branch 2 taken 493208 times.
✓ Branch 3 taken 12040 times.
✓ Branch 4 taken 365430 times.
✓ Branch 5 taken 127778 times.
2616684 if(DrunkDown()&&(holddir==-1||holddir==down))
16185 {
16186
4/8
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 374795 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
377470 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16187 {
16188 }
16189 else
16190 {
16191
3/4
✓ Branch 0 taken 372454 times.
✓ Branch 1 taken 5016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372454 times.
377470 if(charging==0 && spins==0)
16192 {
16193 372454 dir=down;
16194 372454 }
16195
16196 377470 holddir=down;
16197
16198
4/4
✓ Branch 0 taken 62738 times.
✓ Branch 1 taken 314732 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 62440 times.
377470 if(DrunkRight()&&shiftdir!=left)
16199 {
16200 62440 shiftdir=right;
16201 62440 }
16202
4/4
✓ Branch 0 taken 58119 times.
✓ Branch 1 taken 256911 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 58035 times.
315030 else if(DrunkLeft()&&shiftdir!=right)
16203 {
16204 58035 shiftdir=left;
16205 58035 }
16206 else
16207 {
16208 256995 shiftdir=-1;
16209 }
16210
16211 //bool walkable;
16212
7/12
✓ Branch 0 taken 12293 times.
✓ Branch 1 taken 365177 times.
✓ Branch 2 taken 12293 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12293 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12293 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12293 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 12293 times.
377470 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16213 {
16214 12293 walkable=false;
16215 12293 }
16216 else
16217 {
16218 365177 info = walkflag(x,y+15+z3step,2,down);
16219
16220
2/2
✓ Branch 0 taken 202261 times.
✓ Branch 1 taken 162916 times.
365177 if(x.getInt()&7)
16221 202261 info = info || walkflag(x+16,y+15+z3step,1,down);
16222 else
16223 162916 info = info || walkflagMBlock(x+16, y+15+z3step);
16224
16225 365177 execute(info);
16226
16227
2/2
✓ Branch 0 taken 64896 times.
✓ Branch 1 taken 300281 times.
365177 if(info.isUnwalkable())
16228 {
16229
2/2
✓ Branch 0 taken 63721 times.
✓ Branch 1 taken 1175 times.
64896 if(z3step==2)
16230 {
16231 63721 z3step=1;
16232 63721 info = walkflag(x,y+15+z3step,2,down);
16233
16234
2/2
✓ Branch 0 taken 24935 times.
✓ Branch 1 taken 38786 times.
63721 if(x.getInt()&7)
16235 38786 info = info || walkflag(x+16,y+15+z3step,1,down);
16236 else
16237 24935 info = info || walkflagMBlock(x+16, y+15+z3step);
16238
16239 63721 execute(info);
16240
16241
2/2
✓ Branch 0 taken 59220 times.
✓ Branch 1 taken 4501 times.
63721 if(info.isUnwalkable())
16242 {
16243 59220 walkable = false;
16244 59220 }
16245 else
16246 {
16247 4501 walkable=true;
16248 }
16249 63721 }
16250 else
16251 {
16252 1175 walkable=false;
16253 }
16254 64896 }
16255 else
16256 {
16257 300281 walkable = true;
16258 }
16259 }
16260
16261 377470 int32_t s=shiftdir;
16262
16263
5/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 374795 times.
✓ Branch 2 taken 2670 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2675 times.
✗ Branch 5 not taken.
377470 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
16264 {
16265 shiftdir=-1;
16266 }
16267 else
16268 {
16269
2/2
✓ Branch 0 taken 58035 times.
✓ Branch 1 taken 319435 times.
377470 if(s==left)
16270 {
16271 58035 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
16272 58035 execute(info);
16273
16274
2/2
✓ Branch 0 taken 6894 times.
✓ Branch 1 taken 51141 times.
58035 if(info.isUnwalkable())
16275 {
16276 6894 shiftdir=-1;
16277 6894 }
16278
2/2
✓ Branch 0 taken 12561 times.
✓ Branch 1 taken 38580 times.
51141 else if(walkable)
16279 {
16280 38580 info = walkflag(x-1,y+16,1,left);
16281 38580 execute(info);
16282
16283
2/2
✓ Branch 0 taken 38500 times.
✓ Branch 1 taken 80 times.
38580 if(info.isUnwalkable())
16284 {
16285 80 shiftdir=-1;
16286 80 }
16287 38580 }
16288 58035 }
16289
2/2
✓ Branch 0 taken 256995 times.
✓ Branch 1 taken 62440 times.
319435 else if(s==right)
16290 {
16291 62440 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16292 62440 execute(info);
16293
16294
2/2
✓ Branch 0 taken 10015 times.
✓ Branch 1 taken 52425 times.
62440 if(info.isUnwalkable())
16295 {
16296 10015 shiftdir=-1;
16297 10015 }
16298
2/2
✓ Branch 0 taken 12539 times.
✓ Branch 1 taken 39886 times.
52425 else if(walkable)
16299 {
16300 39886 info = walkflag(x+16,y+16,1,right);
16301 39886 execute(info);
16302
16303
2/2
✓ Branch 0 taken 39800 times.
✓ Branch 1 taken 86 times.
39886 if(info.isUnwalkable())
16304 {
16305 86 shiftdir=-1;
16306 86 }
16307 39886 }
16308 62440 }
16309 }
16310
16311 377470 moveOld2(down);
16312 377470 shiftdir=s;
16313
16314
2/2
✓ Branch 0 taken 304782 times.
✓ Branch 1 taken 72688 times.
377470 if(!walkable)
16315 {
16316
2/2
✓ Branch 0 taken 31161 times.
✓ Branch 1 taken 41527 times.
72688 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16317 {
16318
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 41527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41527 times.
✓ Branch 4 taken 24386 times.
✓ Branch 5 taken 17141 times.
✓ Branch 6 taken 1992 times.
✓ Branch 7 taken 39535 times.
58668 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
16319
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17141 times.
✓ Branch 4 taken 5772 times.
✓ Branch 5 taken 11369 times.
17141 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
16320
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11369 times.
11369 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
16321 {
16322
9/12
✓ Branch 0 taken 1867 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 1867 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1867 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1859 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1859 times.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1992 times.
1992 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16323 1992 sprite::move((zfix)-1,(zfix)0);
16324 1992 }
16325
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 39535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39535 times.
✓ Branch 4 taken 15149 times.
✓ Branch 5 taken 24386 times.
✓ Branch 6 taken 1804 times.
✓ Branch 7 taken 37731 times.
63921 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
16326
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24386 times.
✓ Branch 4 taken 22560 times.
✓ Branch 5 taken 1826 times.
24386 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
16327
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1826 times.
1826 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
16328 {
16329
9/12
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 1723 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1723 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1717 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 1717 times.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1804 times.
1804 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16330 1804 sprite::move((zfix)1,(zfix)0);
16331 1804 }
16332 else //if(shiftdir==-1)
16333 {
16334 37731 pushing=push+1;
16335
16336
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 37646 times.
37731 if(action!=swimming)
16337 {
16338 37646 }
16339 }
16340
16341 41527 z3step=2;
16342 41527 }
16343 else
16344 {
16345 31161 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16346
16347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31161 times.
31161 if(action!=swimming)
16348 {
16349 31161 }
16350
16351 31161 z3step=2;
16352 }
16353 72688 }
16354
16355 377470 return;
16356 }
16357 }
16358
16359
6/6
✓ Branch 0 taken 600618 times.
✓ Branch 1 taken 1638596 times.
✓ Branch 2 taken 583622 times.
✓ Branch 3 taken 16996 times.
✓ Branch 4 taken 582008 times.
✓ Branch 5 taken 1614 times.
2239214 if(DrunkLeft()&&(holddir==-1||holddir==left))
16360 {
16361
5/8
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 594342 times.
✓ Branch 2 taken 4511 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4662 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
599004 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
16362 {
16363 }
16364 else
16365 {
16366
3/4
✓ Branch 0 taken 592458 times.
✓ Branch 1 taken 6546 times.
✓ Branch 2 taken 592458 times.
✗ Branch 3 not taken.
599004 if(charging==0 && spins==0)
16367 {
16368 592458 dir=left;
16369 592458 }
16370
16371 599004 holddir=left;
16372
16373
4/4
✓ Branch 0 taken 75929 times.
✓ Branch 1 taken 523075 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 75926 times.
599004 if(DrunkUp()&&shiftdir!=down)
16374 {
16375 75926 shiftdir=up;
16376 75926 }
16377
4/4
✓ Branch 0 taken 61170 times.
✓ Branch 1 taken 461908 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 61158 times.
523078 else if(DrunkDown()&&shiftdir!=up)
16378 {
16379 61158 shiftdir=down;
16380 61158 }
16381 else
16382 {
16383 461920 shiftdir=-1;
16384 }
16385
16386 //bool walkable;
16387 599004 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16388
16389
2/2
✓ Branch 0 taken 254314 times.
✓ Branch 1 taken 344690 times.
599004 if(y.getInt()&7)
16390 344690 info = info || walkflag(x-z3step,y+16,1,left);
16391
16392 599004 execute(info);
16393
16394
2/2
✓ Branch 0 taken 73587 times.
✓ Branch 1 taken 525417 times.
599004 if(info.isUnwalkable())
16395 {
16396
2/2
✓ Branch 0 taken 72185 times.
✓ Branch 1 taken 1402 times.
73587 if(z3step==2)
16397 {
16398 72185 z3step=1;
16399 72185 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16400
16401
2/2
✓ Branch 0 taken 44557 times.
✓ Branch 1 taken 27628 times.
72185 if(y.getInt()&7)
16402 44557 info = info || walkflag(x-z3step,y+16,1,left);
16403
16404 72185 execute(info);
16405
16406
2/2
✓ Branch 0 taken 67321 times.
✓ Branch 1 taken 4864 times.
72185 if(info.isUnwalkable())
16407 {
16408 67321 walkable = false;
16409 67321 }
16410 else
16411 {
16412 4864 walkable=true;
16413 }
16414 72185 }
16415 else
16416 {
16417 1402 walkable=false;
16418 }
16419 73587 }
16420 else
16421 {
16422 525417 walkable = true;
16423 }
16424
16425 599004 int32_t s=shiftdir;
16426
16427
10/14
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 594342 times.
✓ Branch 2 taken 4595 times.
✓ Branch 3 taken 67 times.
✓ Branch 4 taken 4662 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 69998 times.
✓ Branch 7 taken 529006 times.
✓ Branch 8 taken 69998 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 69998 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 69998 times.
✗ Branch 13 not taken.
599004 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16428 {
16429 69998 shiftdir=-1;
16430 69998 }
16431 else
16432 {
16433
2/2
✓ Branch 0 taken 454669 times.
✓ Branch 1 taken 74337 times.
529006 if(s==up)
16434 {
16435 74337 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16436 74337 execute(info);
16437
16438
2/2
✓ Branch 0 taken 8595 times.
✓ Branch 1 taken 65742 times.
74337 if(info.isUnwalkable())
16439 {
16440 8595 shiftdir=-1;
16441 8595 }
16442
2/2
✓ Branch 0 taken 9983 times.
✓ Branch 1 taken 55759 times.
65742 else if(walkable)
16443 {
16444 55759 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
16445 55759 execute(info);
16446
16447
2/2
✓ Branch 0 taken 55678 times.
✓ Branch 1 taken 81 times.
55759 if(info.isUnwalkable())
16448 {
16449 81 shiftdir=-1;
16450 81 }
16451 55759 }
16452 74337 }
16453
2/2
✓ Branch 0 taken 394275 times.
✓ Branch 1 taken 60394 times.
454669 else if(s==down)
16454 {
16455 60394 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16456 60394 execute(info);
16457
16458
2/2
✓ Branch 0 taken 9555 times.
✓ Branch 1 taken 50839 times.
60394 if(info.isUnwalkable())
16459 {
16460 9555 shiftdir=-1;
16461 9555 }
16462
2/2
✓ Branch 0 taken 7945 times.
✓ Branch 1 taken 42894 times.
50839 else if(walkable)
16463 {
16464 42894 info = walkflag(x-1,y+16,1,down);
16465 42894 execute(info);
16466
16467
2/2
✓ Branch 0 taken 42823 times.
✓ Branch 1 taken 71 times.
42894 if(info.isUnwalkable())
16468 {
16469 71 shiftdir=-1;
16470 71 }
16471 42894 }
16472 60394 }
16473 }
16474
16475 599004 moveOld2(left);
16476 599004 shiftdir=s;
16477
16478
2/2
✓ Branch 0 taken 530281 times.
✓ Branch 1 taken 68723 times.
599004 if(!walkable)
16479 {
16480
2/2
✓ Branch 0 taken 22576 times.
✓ Branch 1 taken 46147 times.
68723 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16481 {
16482 46147 int32_t v1=bigHitbox?0:8;
16483 46147 int32_t v2=bigHitbox?8:12;
16484
16485
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46147 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46147 times.
✓ Branch 4 taken 38043 times.
✓ Branch 5 taken 8104 times.
✓ Branch 6 taken 1551 times.
✓ Branch 7 taken 44596 times.
54251 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
16486
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8104 times.
✓ Branch 4 taken 4024 times.
✓ Branch 5 taken 4080 times.
8104 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
16487
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4080 times.
4080 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
16488 {
16489
9/12
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 1422 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1422 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1418 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1418 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1551 times.
1551 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16490 1551 sprite::move((zfix)0,(zfix)-1);
16491 1551 }
16492
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 44596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44596 times.
✓ Branch 4 taken 6553 times.
✓ Branch 5 taken 38043 times.
✓ Branch 6 taken 802 times.
✓ Branch 7 taken 43794 times.
82639 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
16493
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38043 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38043 times.
✓ Branch 4 taken 37241 times.
✓ Branch 5 taken 802 times.
38043 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
16494
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 802 times.
802 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
16495 {
16496
8/12
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 750 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 750 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 750 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 750 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 801 times.
802 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16497 801 sprite::move((zfix)0,(zfix)1);
16498 802 }
16499 else //if(shiftdir==-1)
16500 {
16501 43794 pushing=push+1;
16502
16503
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 43589 times.
43794 if(action!=swimming)
16504 {
16505 43589 }
16506 }
16507
16508 46147 z3step=2;
16509 46147 }
16510 else
16511 {
16512 22576 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16513
16514
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 22533 times.
22576 if(action!=swimming)
16515 {
16516 22533 }
16517
16518 22576 z3step=2;
16519 }
16520 68723 }
16521
16522 599004 return;
16523 }
16524 }
16525
16526
5/6
✓ Branch 0 taken 663276 times.
✓ Branch 1 taken 976934 times.
✓ Branch 2 taken 645546 times.
✓ Branch 3 taken 17730 times.
✓ Branch 4 taken 645546 times.
✗ Branch 5 not taken.
1640210 if(DrunkRight()&&(holddir==-1||holddir==right))
16527 {
16528
5/8
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 658613 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4663 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
663276 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
16529 {
16530 }
16531 else
16532 {
16533
3/4
✓ Branch 0 taken 655145 times.
✓ Branch 1 taken 8131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 655145 times.
663276 if(charging==0 && spins==0)
16534 {
16535 655145 dir=right;
16536 655145 }
16537
16538 663276 holddir=right;
16539
16540
4/4
✓ Branch 0 taken 82864 times.
✓ Branch 1 taken 580412 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 82833 times.
663276 if(DrunkUp()&&shiftdir!=down)
16541 {
16542 82833 shiftdir=up;
16543 82833 }
16544
4/4
✓ Branch 0 taken 66527 times.
✓ Branch 1 taken 513916 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 66514 times.
580443 else if(DrunkDown()&&shiftdir!=up)
16545 {
16546 66514 shiftdir=down;
16547 66514 }
16548 else
16549 {
16550 513929 shiftdir=-1;
16551 }
16552
16553 //bool walkable;
16554 663276 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16555
16556
2/2
✓ Branch 0 taken 374316 times.
✓ Branch 1 taken 288960 times.
663276 if(y.getInt()&7)
16557 374316 info = info || walkflag(x+15+z3step,y+16,1,right);
16558
16559 663276 execute(info);
16560
16561
2/2
✓ Branch 0 taken 90569 times.
✓ Branch 1 taken 572707 times.
663276 if(info.isUnwalkable())
16562 {
16563
2/2
✓ Branch 0 taken 89087 times.
✓ Branch 1 taken 1482 times.
90569 if(z3step==2)
16564 {
16565 89087 z3step=1;
16566 89087 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16567
16568
2/2
✓ Branch 0 taken 33839 times.
✓ Branch 1 taken 55248 times.
89087 if(y.getInt()&7)
16569 55248 info = info || walkflag(x+15+z3step,y+16,1,right);
16570
16571 89087 execute(info);
16572
16573
2/2
✓ Branch 0 taken 81577 times.
✓ Branch 1 taken 7510 times.
89087 if(info.isUnwalkable())
16574 {
16575 81577 walkable = false;
16576 81577 }
16577 else
16578 {
16579 7510 walkable=true;
16580 }
16581 89087 }
16582 else
16583 {
16584 1482 walkable=false;
16585 }
16586 90569 }
16587 else
16588 {
16589 572707 walkable = true;
16590 }
16591
16592 663276 int32_t s=shiftdir;
16593
16594
10/14
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 658613 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 4663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 85857 times.
✓ Branch 7 taken 577419 times.
✓ Branch 8 taken 85857 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 85857 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 85857 times.
✗ Branch 13 not taken.
663276 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16595 {
16596 85857 shiftdir=-1;
16597 85857 }
16598 else
16599 {
16600
2/2
✓ Branch 0 taken 497041 times.
✓ Branch 1 taken 80378 times.
577419 if(s==up)
16601 {
16602 80378 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16603 80378 execute(info);
16604
16605
2/2
✓ Branch 0 taken 10531 times.
✓ Branch 1 taken 69847 times.
80378 if(info.isUnwalkable())
16606 {
16607 10531 shiftdir=-1;
16608 10531 }
16609
2/2
✓ Branch 0 taken 11752 times.
✓ Branch 1 taken 58095 times.
69847 else if(walkable)
16610 {
16611 58095 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
16612 58095 execute(info);
16613
16614
2/2
✓ Branch 0 taken 58004 times.
✓ Branch 1 taken 91 times.
58095 if(info.isUnwalkable())
16615 {
16616 91 shiftdir=-1;
16617 91 }
16618 58095 }
16619 80378 }
16620
2/2
✓ Branch 0 taken 431114 times.
✓ Branch 1 taken 65927 times.
497041 else if(s==down)
16621 {
16622 65927 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16623 65927 execute(info);
16624
16625
2/2
✓ Branch 0 taken 11453 times.
✓ Branch 1 taken 54474 times.
65927 if(info.isUnwalkable())
16626 {
16627 11453 shiftdir=-1;
16628 11453 }
16629
2/2
✓ Branch 0 taken 9326 times.
✓ Branch 1 taken 45148 times.
54474 else if(walkable)
16630 {
16631 45148 info = walkflag(x+16,y+16,1,down);
16632 45148 execute(info);
16633
16634
2/2
✓ Branch 0 taken 45066 times.
✓ Branch 1 taken 82 times.
45148 if(info.isUnwalkable())
16635 {
16636 82 shiftdir=-1;
16637 82 }
16638 45148 }
16639 65927 }
16640 }
16641
16642 663276 moveOld2(right);
16643 663276 shiftdir=s;
16644
16645
2/2
✓ Branch 0 taken 580217 times.
✓ Branch 1 taken 83059 times.
663276 if(!walkable)
16646 {
16647
2/2
✓ Branch 0 taken 27386 times.
✓ Branch 1 taken 55673 times.
83059 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16648 {
16649 55673 int32_t v1=bigHitbox?0:8;
16650 55673 int32_t v2=bigHitbox?8:12;
16651
16652 167019 info = !walkflag(x+16,y+v1,1,right)&&
16653 111346 !walkflag(x+16,y+v2,1,right)&&
16654 55673 walkflag(x+16,y+15,1,right);
16655
16656 //do NOT execute these
16657
2/2
✓ Branch 0 taken 1827 times.
✓ Branch 1 taken 53846 times.
55673 if(info.isUnwalkable())
16658 {
16659
10/12
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 1722 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1722 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1721 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1721 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1826 times.
1827 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16660 1826 sprite::move((zfix)0,(zfix)-1);
16661 1827 }
16662 else
16663 {
16664 161538 info = walkflag(x+16,y+v1, 1,right)&&
16665 107692 !walkflag(x+16,y+v2-1,1,right)&&
16666 53846 !walkflag(x+16,y+15, 1,right);
16667
16668
2/2
✓ Branch 0 taken 939 times.
✓ Branch 1 taken 52907 times.
53846 if(info.isUnwalkable())
16669 {
16670
7/12
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 896 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 896 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 896 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 939 times.
939 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16671 939 sprite::move((zfix)0,(zfix)1);
16672 939 }
16673 else //if(shiftdir==-1)
16674 {
16675 52907 pushing=push+1;
16676 52907 z3step=2;
16677
16678
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 52841 times.
52907 if(action!=swimming)
16679 {
16680 52841 }
16681 }
16682 }
16683
16684 55673 z3step=2;
16685 55673 }
16686 else
16687 {
16688 27386 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16689
16690
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 27376 times.
27386 if(action!=swimming)
16691 {
16692 27376 }
16693
16694 27386 z3step=2;
16695 }
16696 83059 }
16697
16698 663276 return;
16699 }
16700 }
16701 }
16702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1170244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1170244 if(shield_forcedir > -1 && action != rafting)
16703 dir = shield_forcedir;
16704 1170244 int32_t wtry = iswaterex_z3(MAPCOMBO(x,y+15), -1, x,y+15, true, false);
16705 1170244 int32_t wtry8 = iswaterex_z3(MAPCOMBO(x+15,y+15), -1, x+15,y+15, true, false);
16706 1170244 int32_t wtrx = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)), -1, x,y+(bigHitbox?0:8), true, false);
16707 1170244 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)), -1, x+15,y+(bigHitbox?0:8), true, false);
16708 1170244 int32_t wtrc = iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?8:12)), -1, x+8,y+(bigHitbox?8:12), true, false);
16709
16710
8/12
✓ Branch 0 taken 166630 times.
✓ Branch 1 taken 1003614 times.
✓ Branch 2 taken 166630 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 166630 times.
✓ Branch 6 taken 166630 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 163821 times.
✓ Branch 9 taken 2809 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 163821 times.
1170244 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
16711 {
16712
8/12
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 163250 times.
✓ Branch 2 taken 526 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 479 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 479 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 479 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
163821 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
16713 {
16714 //action=swimming;
16715
3/12
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
479 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16716 {
16717 hopclk = 0xFF;
16718 }
16719 479 }
16720 163821 }
16721
16722 1170244 return;
16723 } //endif (LTTPWALK)
16724 3779088 temp_step = hero_newstep;
16725 3779088 temp_x = x;
16726 3779088 temp_y = y;
16727
16728
7/8
✓ Branch 0 taken 2471883 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 2420353 times.
✓ Branch 3 taken 51530 times.
✓ Branch 4 taken 59406 times.
✓ Branch 5 taken 2412477 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59406 times.
3779088 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16729 {
16730
2/4
✓ Branch 0 taken 59406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59406 times.
59406 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16731 goto LEFTRIGHT_NEWMOVE;
16732 59406 else goto LEFTRIGHT_OLDMOVE;
16733 }
16734
16735 // make it easier to get in left & right doors
16736
16737 //ignore ladder for this part. sigh sigh sigh -DD
16738 3719682 oldladderx = ladderx;
16739 3719682 oldladdery = laddery;
16740
2/4
✓ Branch 0 taken 3719682 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3719682 times.
3719682 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16741 {
16742 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16743 {
16744 do
16745 {
16746 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16747 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16748
16749 if(info.isUnwalkable())
16750 {
16751 if(temp_x != int32_t(temp_x))
16752 {
16753 temp_x = floor((double)temp_x);
16754 }
16755 else if(temp_step > 1)
16756 {
16757 if(temp_step != int32_t(temp_step)) //floor
16758 temp_step = floor((double)temp_step);
16759 else --temp_step;
16760 }
16761 else
16762 break;
16763 }
16764 }
16765 while(info.isUnwalkable());
16766
16767 if(!info.isUnwalkable())
16768 {
16769 x = temp_x;
16770 y = temp_y;
16771 hero_newstep = temp_step;
16772 //ONLY process the side-effects of the above walkflag if Hero will actually move
16773 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16774 execute(info);
16775 moveOld2(left);
16776 return;
16777 }
16778 temp_x = x;
16779 temp_y = y;
16780 temp_step = hero_newstep;
16781 }
16782
16783 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16784 {
16785 do
16786 {
16787 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16788 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16789
16790 if(info.isUnwalkable())
16791 {
16792 if(temp_x != int32_t(temp_x))
16793 {
16794 temp_x = floor((double)temp_x);
16795 }
16796 else if(temp_step > 1)
16797 {
16798 if(temp_step != int32_t(temp_step)) //floor
16799 temp_step = floor((double)temp_step);
16800 else --temp_step;
16801 }
16802 else
16803 break;
16804 }
16805 }
16806 while(info.isUnwalkable());
16807
16808 if(!info.isUnwalkable())
16809 {
16810 x = temp_x;
16811 y = temp_y;
16812 hero_newstep = temp_step;
16813 execute(info);
16814 moveOld2(right);
16815 return;
16816 }
16817 temp_x = x;
16818 temp_y = y;
16819 temp_step = hero_newstep;
16820 }
16821
16822 ladderx = oldladderx;
16823 laddery = oldladdery;
16824
16825 if(DrunkUp())
16826 {
16827 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16828 {
16829 if(dir!=up && dir!=down)
16830 {
16831 if(xoff>2&&xoff<6)
16832 {
16833 moveOld2(dir);
16834 }
16835 else if(xoff>=6)
16836 {
16837 moveOld2(right);
16838 }
16839 else if(xoff>=1)
16840 {
16841 moveOld2(left);
16842 }
16843 }
16844 else
16845 {
16846 if(xoff>=4)
16847 {
16848 moveOld2(right);
16849 }
16850 else if(xoff<4)
16851 {
16852 moveOld2(left);
16853 }
16854 }
16855 }
16856 else
16857 {
16858 do
16859 {
16860 if(action==swimming || IsSideSwim() || action == swimhit)
16861 {
16862 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16863
16864 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,STANDING_Z_STATE) &&
16865 !(iswaterex_z3(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
16866 iswaterex_z3(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
16867 info.setUnwalkable(true);
16868 }
16869 else
16870 {
16871 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16872 if(x.getInt() & 7)
16873 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
16874 else
16875 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
16876 }
16877
16878 if(info.isUnwalkable())
16879 {
16880 if(temp_y != int32_t(temp_y))
16881 {
16882 temp_y = floor((double)temp_y);
16883 }
16884 else if(temp_step > 1)
16885 {
16886 if(temp_step != int32_t(temp_step)) //floor
16887 temp_step = floor((double)temp_step);
16888 else --temp_step;
16889 }
16890 else
16891 break;
16892 }
16893 }
16894 while(info.isUnwalkable());
16895
16896 execute(info);
16897
16898 if(!info.isUnwalkable())
16899 {
16900 x = temp_x;
16901 y = temp_y;
16902 hero_newstep = temp_step;
16903 moveOld2(up);
16904 return;
16905 }
16906
16907 if(!DrunkLeft() && !DrunkRight())
16908 {
16909 if(NO_GRIDLOCK)
16910 {
16911 x = x.getInt();
16912 y = y.getInt();
16913 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16914 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16915 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16916 {
16917 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16918 sprite::move((zfix)-1,(zfix)0);
16919 }
16920 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16921 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16922 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16923 {
16924 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16925 sprite::move((zfix)1,(zfix)0);
16926 }
16927 else
16928 {
16929 pushing=push+1;
16930 }
16931 }
16932 else pushing=push+1;
16933
16934 if(charging==0 && spins==0)
16935 {
16936 dir=up;
16937 }
16938
16939 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16940 {
16941 herostep();
16942 }
16943
16944 return;
16945 }
16946 else
16947 {
16948 goto LEFTRIGHT_NEWMOVE;
16949 }
16950 }
16951
16952 return;
16953 }
16954
16955 if(DrunkDown())
16956 {
16957 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16958 {
16959 if(dir!=up && dir!=down)
16960 {
16961 if(xoff>2&&xoff<6)
16962 {
16963 moveOld2(dir);
16964 }
16965 else if(xoff>=6)
16966 {
16967 moveOld2(right);
16968 }
16969 else if(xoff>=1)
16970 {
16971 moveOld2(left);
16972 }
16973 }
16974 else
16975 {
16976 if(xoff>=4)
16977 {
16978 moveOld2(right);
16979 }
16980 else if(xoff<4)
16981 {
16982 moveOld2(left);
16983 }
16984 }
16985 }
16986 else
16987 {
16988 do
16989 {
16990 if(action==swimming || IsSideSwim() || action == swimhit)
16991 {
16992 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16993
16994 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,STANDING_Z_STATE) &&
16995 !(iswaterex_z3(MAPCOMBO(temp_x, temp_y+15+temp_step), -1, temp_x, temp_y+15+temp_step, true, false) &&
16996 iswaterex_z3(MAPCOMBO(temp_x+15, temp_y+15+temp_step), -1, temp_x+15, temp_y+15+temp_step, true, false)))
16997 info.setUnwalkable(true);
16998 }
16999 else
17000 {
17001 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17002 if(x.getInt() & 7)
17003 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
17004 else
17005 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
17006 }
17007
17008 if(info.isUnwalkable())
17009 {
17010 if(temp_y != int32_t(temp_y))
17011 {
17012 temp_y = floor((double)temp_y);
17013 }
17014 else if(temp_step > 1)
17015 {
17016 if(temp_step != int32_t(temp_step)) //floor
17017 temp_step = floor((double)temp_step);
17018 else --temp_step;
17019 }
17020 else
17021 break;
17022 }
17023 }
17024 while(info.isUnwalkable());
17025
17026 execute(info);
17027
17028 if(!info.isUnwalkable())
17029 {
17030 x = temp_x;
17031 y = temp_y;
17032 hero_newstep = temp_step;
17033 moveOld2(down);
17034 return;
17035 }
17036
17037 if(!DrunkLeft() && !DrunkRight())
17038 {
17039 if(NO_GRIDLOCK)
17040 {
17041 x = x.getInt();
17042 y = y.getInt();
17043 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17044 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
17045 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17046 {
17047 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17048 sprite::move((zfix)-1,(zfix)0);
17049 }
17050 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17051 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
17052 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17053 {
17054 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17055 sprite::move((zfix)1,(zfix)0);
17056 }
17057 else
17058 {
17059 pushing=push+1;
17060 }
17061 }
17062 else pushing=push+1;
17063
17064 if(charging==0 && spins==0)
17065 {
17066 dir=down;
17067 }
17068
17069 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17070 {
17071 herostep();
17072 }
17073
17074 return;
17075 }
17076 else goto LEFTRIGHT_NEWMOVE;
17077 }
17078
17079 return;
17080 }
17081
17082 LEFTRIGHT_NEWMOVE:
17083 temp_x = x;
17084 temp_y = y;
17085 temp_step = hero_newstep;
17086 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17087 {
17088 return;
17089 }
17090
17091 if(DrunkLeft())
17092 {
17093 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17094 {
17095 if(dir!=left && dir!=right)
17096 {
17097 if(yoff>2&&yoff<6)
17098 {
17099 moveOld2(dir);
17100 }
17101 else if(yoff>=6)
17102 {
17103 moveOld2(down);
17104 }
17105 else if(yoff>=1)
17106 {
17107 moveOld2(up);
17108 }
17109 }
17110 else
17111 {
17112 if(yoff>=4)
17113 {
17114 moveOld2(down);
17115 }
17116 else if(yoff<4)
17117 {
17118 moveOld2(up);
17119 }
17120 }
17121 }
17122 else
17123 {
17124 do
17125 {
17126 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
17127 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
17128
17129 if(y.getInt() & 7)
17130 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
17131
17132 if(info.isUnwalkable())
17133 {
17134 if(temp_x != int32_t(temp_x))
17135 {
17136 temp_x = floor((double)temp_x);
17137 }
17138 else if(temp_step > 1)
17139 {
17140 if(temp_step != int32_t(temp_step)) //floor
17141 temp_step = floor((double)temp_step);
17142 else --temp_step;
17143 }
17144 else
17145 break;
17146 }
17147 }
17148 while(info.isUnwalkable());
17149
17150 execute(info);
17151
17152 if(!info.isUnwalkable())
17153 {
17154 x = temp_x;
17155 y = temp_y;
17156 hero_newstep = temp_step;
17157 moveOld2(left);
17158 return;
17159 }
17160
17161 if(!DrunkUp() && !DrunkDown())
17162 {
17163 if(NO_GRIDLOCK)
17164 {
17165 x = x.getInt();
17166 y = y.getInt();
17167 int32_t v1=bigHitbox?0:8;
17168 int32_t v2=bigHitbox?8:12;
17169
17170 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17171 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
17172 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
17173 {
17174 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17175 sprite::move((zfix)0,(zfix)-1);
17176 }
17177 else if(_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17178 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
17179 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
17180 {
17181 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17182 sprite::move((zfix)0,(zfix)1);
17183 }
17184 else
17185 {
17186 pushing=push+1;
17187 }
17188 }
17189 else pushing=push+1;
17190
17191 if(charging==0 && spins==0)
17192 {
17193 dir=left;
17194 }
17195
17196 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17197 {
17198 herostep();
17199 }
17200
17201 return;
17202 }
17203 }
17204
17205 return;
17206 }
17207
17208 if(DrunkRight())
17209 {
17210 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17211 {
17212 if(dir!=left && dir!=right)
17213 {
17214 if(yoff>2&&yoff<6)
17215 {
17216 moveOld2(dir);
17217 }
17218 else if(yoff>=6)
17219 {
17220 moveOld2(down);
17221 }
17222 else if(yoff>=1)
17223 {
17224 moveOld2(up);
17225 }
17226 }
17227 else
17228 {
17229 if(yoff>=4)
17230 {
17231 moveOld2(down);
17232 }
17233 else if(yoff<4)
17234 {
17235 moveOld2(up);
17236 }
17237 }
17238 }
17239 else
17240 {
17241 do
17242 {
17243 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
17244 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
17245
17246 if(y.getInt() & 7)
17247 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
17248
17249 if(info.isUnwalkable())
17250 {
17251 if(temp_x != int32_t(temp_x))
17252 {
17253 temp_x = floor((double)temp_x);
17254 }
17255 else if(temp_step > 1)
17256 {
17257 if(temp_step != int32_t(temp_step)) //floor
17258 temp_step = floor((double)temp_step);
17259 else --temp_step;
17260 }
17261 else
17262 break;
17263 }
17264 }
17265 while(info.isUnwalkable());
17266
17267 execute(info);
17268
17269 if(!info.isUnwalkable())
17270 {
17271 x = temp_x;
17272 y = temp_y;
17273 hero_newstep = temp_step;
17274 moveOld2(right);
17275 return;
17276 }
17277
17278 if(!DrunkUp() && !DrunkDown())
17279 {
17280 if(NO_GRIDLOCK)
17281 {
17282 x = x.getInt();
17283 y = y.getInt();
17284 int32_t v1=bigHitbox?0:8;
17285 int32_t v2=bigHitbox?8:12;
17286
17287 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17288 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
17289 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
17290 {
17291 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17292 sprite::move((zfix)0,(zfix)-1);
17293 }
17294 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17295 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
17296 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
17297 {
17298 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17299 sprite::move((zfix)0,(zfix)1);
17300 }
17301 else
17302 {
17303 pushing=push+1;
17304 }
17305 }
17306 else pushing=push+1;
17307
17308 if(charging==0 && spins==0)
17309 {
17310 dir=right;
17311 }
17312
17313 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17314 {
17315 herostep();
17316 }
17317
17318 return;
17319 }
17320 }
17321 }
17322 }
17323 else
17324 {
17325 7439364 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17326 3719682 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
17327
17328
10/10
✓ Branch 0 taken 2412477 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 304272 times.
✓ Branch 3 taken 2108205 times.
✓ Branch 4 taken 186363 times.
✓ Branch 5 taken 117909 times.
✓ Branch 6 taken 1889 times.
✓ Branch 7 taken 184474 times.
✓ Branch 8 taken 358 times.
✓ Branch 9 taken 1531 times.
3719682 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
17329 {
17330 //ONLY process the side-effects of the above walkflag if Hero will actually move
17331 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
17332 1531 execute(info);
17333 1531 moveOld2(left);
17334 1531 return;
17335 }
17336
17337 7436302 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
17338 3718151 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
17339
17340
10/10
✓ Branch 0 taken 2410946 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 337880 times.
✓ Branch 3 taken 2073066 times.
✓ Branch 4 taken 201211 times.
✓ Branch 5 taken 136669 times.
✓ Branch 6 taken 2221 times.
✓ Branch 7 taken 198990 times.
✓ Branch 8 taken 406 times.
✓ Branch 9 taken 1815 times.
3718151 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
17341 {
17342 1815 execute(info);
17343 1815 moveOld2(right);
17344 1815 return;
17345 }
17346
17347 3716336 ladderx = oldladderx;
17348 3716336 laddery = oldladdery;
17349
17350
2/2
✓ Branch 0 taken 416069 times.
✓ Branch 1 taken 3300267 times.
3716336 if(DrunkUp())
17351 {
17352
11/14
✓ Branch 0 taken 11759 times.
✓ Branch 1 taken 404310 times.
✓ Branch 2 taken 10988 times.
✓ Branch 3 taken 771 times.
✓ Branch 4 taken 8233 times.
✓ Branch 5 taken 2755 times.
✓ Branch 6 taken 8233 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8233 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8233 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 8230 times.
416069 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17353 {
17354
4/4
✓ Branch 0 taken 8196 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 8195 times.
8230 if(dir!=up && dir!=down)
17355 {
17356
4/4
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 2427 times.
✓ Branch 3 taken 3266 times.
8195 if(xoff>2&&xoff<6)
17357 {
17358 3266 moveOld2(dir);
17359 3266 }
17360
2/2
✓ Branch 0 taken 2427 times.
✓ Branch 1 taken 2502 times.
4929 else if(xoff>=6)
17361 {
17362 2427 moveOld2(right);
17363 2427 }
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2502 times.
2502 else if(xoff>=1)
17365 {
17366 2502 moveOld2(left);
17367 2502 }
17368 8195 }
17369 else
17370 {
17371
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 25 times.
35 if(xoff>=4)
17372 {
17373 10 moveOld2(right);
17374 10 }
17375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(xoff<4)
17376 {
17377 25 moveOld2(left);
17378 25 }
17379 }
17380 8230 }
17381 else
17382 {
17383
4/6
✓ Branch 0 taken 381459 times.
✓ Branch 1 taken 26380 times.
✓ Branch 2 taken 381459 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 381459 times.
407839 if(action==swimming || IsSideSwim() || action == swimhit)
17384 {
17385 26380 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17386
17387
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 26380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26380 times.
✓ Branch 4 taken 2023 times.
✓ Branch 5 taken 24357 times.
✓ Branch 6 taken 21669 times.
✓ Branch 7 taken 4711 times.
50737 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,STANDING_Z_STATE) &&
17388
2/2
✓ Branch 0 taken 4471 times.
✓ Branch 1 taken 19886 times.
44243 !(iswaterex_z3(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
17389 19886 iswaterex_z3(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
17390 4711 info.setUnwalkable(true);
17391 26380 }
17392 else
17393 {
17394 381459 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17395
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 380682 times.
381459 if(x.getInt() & 7)
17396 777 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
17397 else
17398 380682 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
17399 }
17400
17401 407839 execute(info);
17402
17403
2/2
✓ Branch 0 taken 169874 times.
✓ Branch 1 taken 237965 times.
407839 if(!info.isUnwalkable())
17404 {
17405 237965 moveOld2(up);
17406 237965 return;
17407 }
17408
17409
4/4
✓ Branch 0 taken 151091 times.
✓ Branch 1 taken 18783 times.
✓ Branch 2 taken 18777 times.
✓ Branch 3 taken 132314 times.
169874 if(!DrunkLeft() && !DrunkRight())
17410 {
17411
2/4
✓ Branch 0 taken 132314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132314 times.
132314 if(NO_GRIDLOCK)
17412 {
17413 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17414 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17415 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17416 {
17417 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17418 sprite::move((zfix)-1,(zfix)0);
17419 }
17420 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17421 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17422 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17423 {
17424 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17425 sprite::move((zfix)1,(zfix)0);
17426 }
17427 else
17428 {
17429 pushing=push+1;
17430 }
17431 }
17432 132314 else pushing=push+1;
17433
17434
4/4
✓ Branch 0 taken 132131 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 132035 times.
✓ Branch 3 taken 96 times.
132314 if(charging==0 && spins==0)
17435 {
17436 132035 dir=up;
17437 132035 }
17438
17439
5/8
✓ Branch 0 taken 129287 times.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 129287 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129287 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129287 times.
132314 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17440 {
17441 129287 herostep();
17442 129287 }
17443
17444 132314 return;
17445 }
17446 else
17447 {
17448 37560 goto LEFTRIGHT_OLDMOVE;
17449 }
17450 }
17451
17452 8230 return;
17453 }
17454
17455
2/2
✓ Branch 0 taken 370315 times.
✓ Branch 1 taken 2929952 times.
3300267 if(DrunkDown())
17456 {
17457
11/14
✓ Branch 0 taken 10694 times.
✓ Branch 1 taken 359621 times.
✓ Branch 2 taken 9975 times.
✓ Branch 3 taken 719 times.
✓ Branch 4 taken 6694 times.
✓ Branch 5 taken 3281 times.
✓ Branch 6 taken 6694 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6694 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6694 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 6693 times.
370315 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17458 {
17459
3/4
✓ Branch 0 taken 6693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6690 times.
6693 if(dir!=up && dir!=down)
17460 {
17461
4/4
✓ Branch 0 taken 4676 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 2001 times.
✓ Branch 3 taken 2675 times.
6690 if(xoff>2&&xoff<6)
17462 {
17463 2675 moveOld2(dir);
17464 2675 }
17465
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2014 times.
4015 else if(xoff>=6)
17466 {
17467 2001 moveOld2(right);
17468 2001 }
17469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2014 times.
2014 else if(xoff>=1)
17470 {
17471 2014 moveOld2(left);
17472 2014 }
17473 6690 }
17474 else
17475 {
17476
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(xoff>=4)
17477 {
17478 3 moveOld2(right);
17479 3 }
17480 else if(xoff<4)
17481 {
17482 moveOld2(left);
17483 }
17484 }
17485 6693 }
17486 else
17487 {
17488
4/6
✓ Branch 0 taken 340096 times.
✓ Branch 1 taken 23526 times.
✓ Branch 2 taken 340096 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 340096 times.
363622 if(action==swimming || IsSideSwim() || action == swimhit)
17489 {
17490 23526 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17491
17492
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23526 times.
✓ Branch 4 taken 2312 times.
✓ Branch 5 taken 21214 times.
✓ Branch 6 taken 17545 times.
✓ Branch 7 taken 5981 times.
44740 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,STANDING_Z_STATE) &&
17493
2/2
✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 15428 times.
36642 !(iswaterex_z3(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
17494 15428 iswaterex_z3(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
17495 5981 info.setUnwalkable(true);
17496 23526 }
17497 else
17498 {
17499 340096 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17500
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 339372 times.
340096 if(x.getInt() & 7)
17501 724 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
17502 else
17503 339372 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
17504 }
17505
17506 363622 execute(info);
17507
17508
2/2
✓ Branch 0 taken 167095 times.
✓ Branch 1 taken 196527 times.
363622 if(!info.isUnwalkable())
17509 {
17510 196527 moveOld2(down);
17511 196527 return;
17512 }
17513
17514
4/4
✓ Branch 0 taken 146281 times.
✓ Branch 1 taken 20814 times.
✓ Branch 2 taken 20409 times.
✓ Branch 3 taken 125872 times.
167095 if(!DrunkLeft() && !DrunkRight())
17515 {
17516
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(NO_GRIDLOCK)
17517 {
17518 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17519 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
17520 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17521 {
17522 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17523 sprite::move((zfix)-1,(zfix)0);
17524 }
17525 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17526 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
17527 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17528 {
17529 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17530 sprite::move((zfix)1,(zfix)0);
17531 }
17532 else
17533 {
17534 pushing=push+1;
17535 }
17536 }
17537 125872 else pushing=push+1;
17538
17539
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125872 times.
✗ Branch 3 not taken.
125872 if(charging==0 && spins==0)
17540 {
17541 125872 dir=down;
17542 125872 }
17543
17544
5/8
✓ Branch 0 taken 123206 times.
✓ Branch 1 taken 2666 times.
✓ Branch 2 taken 123206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123206 times.
125872 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17545 {
17546 123206 herostep();
17547 123206 }
17548
17549 125872 return;
17550 }
17551 41223 else goto LEFTRIGHT_OLDMOVE;
17552 }
17553
17554 6693 return;
17555 }
17556
17557 LEFTRIGHT_OLDMOVE:
17558
17559
7/8
✓ Branch 0 taken 2014946 times.
✓ Branch 1 taken 1053195 times.
✓ Branch 2 taken 1959592 times.
✓ Branch 3 taken 55354 times.
✓ Branch 4 taken 55639 times.
✓ Branch 5 taken 1959307 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55639 times.
3068141 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
17560 {
17561 55639 return;
17562 }
17563
17564
2/2
✓ Branch 0 taken 462695 times.
✓ Branch 1 taken 2549807 times.
3012502 if(DrunkLeft())
17565 {
17566
11/14
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 454280 times.
✓ Branch 2 taken 7962 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 7343 times.
✓ Branch 5 taken 619 times.
✓ Branch 6 taken 7343 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7343 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7343 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7341 times.
462695 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17567 {
17568
3/4
✓ Branch 0 taken 7332 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7332 times.
7341 if(dir!=left && dir!=right)
17569 {
17570
4/4
✓ Branch 0 taken 5180 times.
✓ Branch 1 taken 2152 times.
✓ Branch 2 taken 2240 times.
✓ Branch 3 taken 2940 times.
7332 if(yoff>2&&yoff<6)
17571 {
17572 2940 moveOld2(dir);
17573 2940 }
17574
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 2152 times.
4392 else if(yoff>=6)
17575 {
17576 2240 moveOld2(down);
17577 2240 }
17578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2152 times.
2152 else if(yoff>=1)
17579 {
17580 2152 moveOld2(up);
17581 2152 }
17582 7332 }
17583 else
17584 {
17585
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(yoff>=4)
17586 {
17587 6 moveOld2(down);
17588 6 }
17589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(yoff<4)
17590 {
17591 3 moveOld2(up);
17592 3 }
17593 }
17594 7341 }
17595 else
17596 {
17597 910708 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17598 455354 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
17599
17600 455354 execute(info);
17601
17602
2/2
✓ Branch 0 taken 164089 times.
✓ Branch 1 taken 291265 times.
455354 if(!info.isUnwalkable())
17603 {
17604 291265 moveOld2(left);
17605 291265 return;
17606 }
17607
17608
4/4
✓ Branch 0 taken 156076 times.
✓ Branch 1 taken 8013 times.
✓ Branch 2 taken 8593 times.
✓ Branch 3 taken 147483 times.
164089 if(!DrunkUp() && !DrunkDown())
17609 {
17610
2/4
✓ Branch 0 taken 147483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147483 times.
147483 if(NO_GRIDLOCK)
17611 {
17612 int32_t v1=bigHitbox?0:8;
17613 int32_t v2=bigHitbox?8:12;
17614
17615 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17616 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
17617 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
17618 {
17619 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17620 sprite::move((zfix)0,(zfix)-1);
17621 }
17622 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
17623 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
17624 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
17625 {
17626 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17627 sprite::move((zfix)0,(zfix)1);
17628 }
17629 else
17630 {
17631 pushing=push+1;
17632 }
17633 }
17634 147483 else pushing=push+1;
17635
17636
3/4
✓ Branch 0 taken 147477 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147477 times.
147483 if(charging==0 && spins==0)
17637 {
17638 147477 dir=left;
17639 147477 }
17640
17641
5/8
✓ Branch 0 taken 143688 times.
✓ Branch 1 taken 3795 times.
✓ Branch 2 taken 143688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143688 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 143688 times.
147483 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17642 {
17643 143688 herostep();
17644 143688 }
17645
17646 147483 return;
17647 }
17648 }
17649
17650 23947 return;
17651 }
17652
17653
2/2
✓ Branch 0 taken 2047980 times.
✓ Branch 1 taken 501827 times.
2549807 if(DrunkRight())
17654 {
17655
10/14
✓ Branch 0 taken 8229 times.
✓ Branch 1 taken 493598 times.
✓ Branch 2 taken 7620 times.
✓ Branch 3 taken 609 times.
✓ Branch 4 taken 7422 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 7422 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7422 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7422 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 7422 times.
501827 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17656 {
17657
4/4
✓ Branch 0 taken 7419 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 7410 times.
7422 if(dir!=left && dir!=right)
17658 {
17659
4/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 2142 times.
✓ Branch 2 taken 2234 times.
✓ Branch 3 taken 3034 times.
7410 if(yoff>2&&yoff<6)
17660 {
17661 3034 moveOld2(dir);
17662 3034 }
17663
2/2
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 2142 times.
4376 else if(yoff>=6)
17664 {
17665 2234 moveOld2(down);
17666 2234 }
17667
1/2
✓ Branch 0 taken 2142 times.
✗ Branch 1 not taken.
2142 else if(yoff>=1)
17668 {
17669 2142 moveOld2(up);
17670 2142 }
17671 7410 }
17672 else
17673 {
17674
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(yoff>=4)
17675 {
17676 6 moveOld2(down);
17677 6 }
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(yoff<4)
17679 {
17680 6 moveOld2(up);
17681 6 }
17682 }
17683 7422 }
17684 else
17685 {
17686 988810 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
17687 494405 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
17688
17689 494405 execute(info);
17690
17691
2/2
✓ Branch 0 taken 181175 times.
✓ Branch 1 taken 313230 times.
494405 if(!info.isUnwalkable())
17692 {
17693 313230 moveOld2(right);
17694 313230 return;
17695 }
17696
17697
4/4
✓ Branch 0 taken 174556 times.
✓ Branch 1 taken 6619 times.
✓ Branch 2 taken 8011 times.
✓ Branch 3 taken 166545 times.
181175 if(!DrunkUp() && !DrunkDown())
17698 {
17699
2/4
✓ Branch 0 taken 166545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166545 times.
166545 if(NO_GRIDLOCK)
17700 {
17701 int32_t v1=bigHitbox?0:8;
17702 int32_t v2=bigHitbox?8:12;
17703
17704 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17705 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
17706 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
17707 {
17708 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17709 sprite::move((zfix)0,(zfix)-1);
17710 }
17711 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17712 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
17713 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
17714 {
17715 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17716 sprite::move((zfix)0,(zfix)1);
17717 }
17718 else
17719 {
17720 pushing=push+1;
17721 }
17722 }
17723 166545 else pushing=push+1;
17724
17725
2/4
✓ Branch 0 taken 166545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166545 times.
166545 if(charging==0 && spins==0)
17726 {
17727 166545 dir=right;
17728 166545 }
17729
17730
5/8
✓ Branch 0 taken 164951 times.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 164951 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 164951 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 164951 times.
166545 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17731 {
17732 164951 herostep();
17733 164951 }
17734
17735 166545 return;
17736 }
17737 }
17738 22052 }
17739 }
17740 13292579 }
17741
17742 4474617 bool HeroClass::scr_walkflag(zfix_round zdx,zfix_round zdy,int d2,bool kb, int* canladder)
17743 {
17744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4474617 times.
4474617 if(toogam) return false;
17745 4474617 int dx = zdx.getRound(), dy = zdy.getRound();
17746
17747
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4474617 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4474617 if(blockpath && dy<80) //Blocked top parts of rooms
17748 return true;
17749
17750
4/4
✓ Branch 0 taken 30097 times.
✓ Branch 1 taken 4444520 times.
✓ Branch 2 taken 18818 times.
✓ Branch 3 taken 11279 times.
4474617 if(mblock2.active() && mblock2.hit(dx,dy,0,1,1,1))
17751 11279 return true;
17752 //collide_object handled in scr_canmove
17753
17754
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3779412 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4463338 times.
4487117 if(isdungeon() && cur_screen<128 && dy<40
17755
5/10
✓ Branch 0 taken 23779 times.
✓ Branch 1 taken 660147 times.
✓ Branch 2 taken 13692 times.
✓ Branch 3 taken 10087 times.
✓ Branch 4 taken 13692 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
683926 && ((x<=112||x>=128) || _walkflag(120,24,2,STANDING_Z_STATE))
17756
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
23779 && !get_qr(qr_FREEFORM))
17757 return true; //Old NES dungeon stuff
17758
17759
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4463338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4463338 times.
4463338 bool solid = _walkflag(zdx,zdy,1,STANDING_Z_STATE);
17760
17761
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3779412 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 683926 times.
✗ Branch 5 not taken.
4463338 if(isdungeon() && cur_screen<128 && !get_qr(qr_FREEFORM))
17762 {
17763 if(dx>=112&&dx<120&&dy<40&&dy>=32)
17764 solid=true;
17765
17766 if(dx>=136&&dx<144&&dy<40&&dy>=32)
17767 solid=true;
17768 }
17769
17770
3/4
✓ Branch 0 taken 4426559 times.
✓ Branch 1 taken 36779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4426559 times.
4463338 if(action==swimming || IsSideSwim())
17771 {
17772
2/2
✓ Branch 0 taken 13463 times.
✓ Branch 1 taken 23316 times.
36779 if(!solid)
17773 {
17774 23316 int ls = 22;
17775
1/6
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23316 if((get_qr(qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_qr(qr_NO_HOPPING))
17776 23316 ls = 1;
17777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23316 times.
23316 if(landswim < ls)
17778 {
17779
2/4
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23316 times.
23316 if(dx<0||dy<0);
17780
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 23296 times.
23316 else if(dx>=256);
17781
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 23278 times.
23296 else if(dy>=176);
17782
2/4
✓ Branch 0 taken 23278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23278 times.
23278 else if(get_qr(qr_DROWN) && !ilswim);
17783 else if(iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17784 solid = false;
17785 else
17786 solid = true;
17787 23316 }
17788 23316 }
17789 else
17790 {
17791 13463 int32_t wtrx = iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy);
17792
17793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13463 times.
13463 if(wtrx)
17794 solid = false;
17795 }
17796 36779 }
17797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
4426559 else if(ladderx+laddery) // ladder is being used
17798 {
17799 if (canladder)
17800 {
17801 *canladder = 0;
17802 }
17803 int32_t lx = zfix(dx);
17804 int32_t ly = zfix(dy);
17805
17806 if(ladderdir<=down) //vertical ladder
17807 {
17808 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17809 {
17810 bool temp = false;
17811
17812 if(!(abs(lx-(ladderx+8))<=8))
17813 temp = true;
17814
17815 if(!temp)
17816 {
17817 solid = false;
17818 }
17819 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17820 {
17821 solid = true;
17822 }
17823 }
17824 }
17825 else //horizontal ladder
17826 {
17827 if(abs(lx-(ladderx+8))<=8)
17828 {
17829 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17830 {
17831 solid = false;
17832 }
17833 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17834 {
17835 solid = true;
17836 }
17837 else if((abs(ly-laddery+8)<=8) && d2<=down)
17838 {
17839 solid = false;
17840 }
17841 }
17842 }
17843 }
17844
5/6
✓ Branch 0 taken 2179566 times.
✓ Branch 1 taken 2246993 times.
✓ Branch 2 taken 2175959 times.
✓ Branch 3 taken 3607 times.
✓ Branch 4 taken 2175959 times.
✗ Branch 5 not taken.
4426559 else if(solid || isSideViewHero() || get_qr(qr_DROWN))
17845 {
17846 // see if it's a good spot for the ladder or for swimming
17847
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4426559 times.
4426559 bool unwalkablex = _walkflag(zdx,zdy,1,STANDING_Z_STATE); //will be used later for the ladder -DD
17848
17849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
4426559 if(get_qr(qr_DROWN))
17850 {
17851 // Drowning changes the following attributes:
17852 // * Dangerous water is also walkable, so ignore the previous
17853 // definitions of unwalkablex.
17854 // * Instead, prevent the ladder from being used in the
17855 // one frame where Hero has landed on water before drowning.
17856 4426559 unwalkablex = !iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11);
17857 4426559 }
17858
17859 // check if he can swim
17860
4/6
✓ Branch 0 taken 431507 times.
✓ Branch 1 taken 3995052 times.
✓ Branch 2 taken 431507 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 431507 times.
4426559 if(current_item(itype_flippers) && z==0 && fakez==0)
17861 {
17862 431507 int32_t wtrx = iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy);
17863
5/6
✓ Branch 0 taken 431333 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 893 times.
✓ Branch 3 taken 430440 times.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
431507 if (current_item(itype_flippers) >= combobuf[wtrx].attribytes[0] && (!(combobuf[wtrx].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
17864 {
17865 //ladder ignores water combos that are now walkable thanks to flippers -DD
17866
2/2
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 426751 times.
431333 unwalkablex = unwalkablex && (!wtrx);
17867
17868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431333 times.
431333 if(landswim >= 22)
17869 {
17870 solid = false;
17871 }
17872
2/2
✓ Branch 0 taken 426996 times.
✓ Branch 1 taken 4337 times.
431333 else if(wtrx)
17873 {
17874
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 3339 times.
4337 if(dir==d2)
17875 {
17876 3339 ladderx = 0;
17877 3339 laddery = 0;
17878 3339 }
17879 4337 }
17880 431333 }
17881 431507 }
17882
17883 // check if he can use the ladder
17884 // "Allow Ladder Anywhere" is toggled by fLADDER
17885
1/2
✓ Branch 0 taken 4426559 times.
✗ Branch 1 not taken.
4426559 if(can_deploy_ladder())
17886 // laddersetup
17887 {
17888 // Check if there's water to use the ladder over
17889 bool wtrx = (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy) != 0);
17890 int32_t ldrid = current_item_id(itype_ladder);
17891 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
17892
17893 if(wtrx)
17894 {
17895 if(isSideViewHero())
17896 {
17897 wtrx = !_walkflag(zdx, zdy+8, 1,STANDING_Z_STATE) && !_walkflag(dx, dy, 1,STANDING_Z_STATE) && dir!=down;
17898 }
17899 // * walk on half-water using the ladder instead of using flippers.
17900 // * otherwise, walk on ladder(+hookshot) combos.
17901 else if((isstepable(MAPCOMBO(dx, dy)) || wtrx==true))
17902 {
17903 if(!get_qr(qr_OLD_210_WATER) && current_item(itype_flippers))
17904 {
17905 //if Hero could swim on a tile instead of using the ladder,
17906 //refuse to use the ladder to step over that tile. -DD
17907 wtrx = isstepable(MAPCOMBO(dx, dy)) && unwalkablex;
17908 }
17909 }
17910 }
17911 else
17912 {
17913 // No water; check other things
17914
17915 //Check pits
17916 if(ladderpits)
17917 {
17918 int32_t pit_cmb = getpitfall(dx,dy);
17919 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17920 }
17921 if(!ladderpits || (!wtrx || isSideViewHero())) //If no pit, check ladder combos
17922 {
17923 int32_t combo=combobuf[MAPCOMBO(dx, dy)].type;
17924 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17925 }
17926 }
17927
17928 for (int32_t i = 1; i <= 2; ++i)
17929 {
17930 if (get_scr_layer_valid(hero_screen, i))
17931 {
17932 if (get_qr(qr_OLD_BRIDGE_COMBOS))
17933 {
17934 if (combobuf[MAPCOMBO2(i-1,dx,dy)].type == cBRIDGE && !_walkflag_layer(dx,dy)) wtrx = false;
17935 }
17936 else
17937 {
17938 if (combobuf[MAPCOMBO2(i-1,dx,dy)].type == cBRIDGE && _effectflag_layer(dx,dy)) wtrx = false;
17939 }
17940 }
17941 }
17942 bool walkwater = (get_qr(qr_DROWN) && !iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy));
17943
17944 if (!wtrx && solid)
17945 {
17946 if (canladder)
17947 {
17948 *canladder = 0;
17949 }
17950 }
17951
17952 if(d2==dir)
17953 {
17954 int32_t c = walkwater ? 0:8;
17955 int32_t b = walkwater ? 8:0;
17956
17957 if(d2>=left)
17958 {
17959 if (wtrx)
17960 {
17961 //If the difference between dy and y is small enough
17962 //this is apparently a really crappy corner shove check?
17963 if((replay_version_check(26)) || (abs((dy)-(int32_t(y+c)))<=(b)))
17964 {
17965 // Don't activate the ladder if it would be entirely
17966 // over water and Hero has the flippers. This isn't
17967 // a good way to do this, but it's too risky
17968 // to make big changes to this stuff.
17969 bool deployLadder=true;
17970 int32_t lx=dx&0xF0;
17971 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex_z3(MAPCOMBO(lx+8, y+8), -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17972 {
17973 if(iswaterex_z3(MAPCOMBO(lx, y), -1, lx, y) &&
17974 iswaterex_z3(MAPCOMBO(lx+15, y), -1, lx+15, y) &&
17975 iswaterex_z3(MAPCOMBO(lx, y+15), -1, lx, y+15) &&
17976 iswaterex_z3(MAPCOMBO(lx+15, y+15), -1, lx+15, y+15))
17977 deployLadder=false;
17978 }
17979 if(deployLadder)
17980 {
17981 if (replay_version_check(26))
17982 {
17983 if (canladder)
17984 {
17985 if (*canladder == -1) *canladder = 1;
17986 }
17987 }
17988 else
17989 {
17990 ladderx = dx&0xF0;
17991 laddery = y;
17992 ladderdir = left;
17993 ladderstart = d2;
17994 solid = laddery!=y.getInt();
17995 }
17996 }
17997 }
17998 }
17999 }
18000 else if(d2<=down)
18001 {
18002 if (wtrx)
18003 {
18004 //Unsure if this actually needs a replay check but better safe than sorry?
18005 if (replay_version_check(26))
18006 {
18007 if (canladder)
18008 {
18009 if (*canladder == -1) *canladder = 1;
18010 }
18011 }
18012 // If the difference between dx and x is small enough
18013 if(!replay_version_check(26) && (abs((dx)-(int32_t(x+c)))<=(b)))
18014 {
18015 ladderx = x;
18016 laddery = dy&0xF0;
18017 ladderdir = up;
18018 ladderstart = d2;
18019 solid = ladderx!=x.getInt();
18020 }
18021 }
18022 }
18023 }
18024 }
18025 4426559 }
18026
18027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4463338 times.
4463338 if (replay_version_check(26))
18028 {
18029
2/2
✓ Branch 0 taken 3241429 times.
✓ Branch 1 taken 1221909 times.
4463338 if (canladder)
18030 {
18031
3/4
✓ Branch 0 taken 1355349 times.
✓ Branch 1 taken 1886080 times.
✓ Branch 2 taken 1355349 times.
✗ Branch 3 not taken.
3241429 if (solid && *canladder == 1) *canladder = 2;
18032 3241429 }
18033 4463338 }
18034
18035 4463338 return solid;
18036 4474617 }
18037
18038 1484257 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv, int* canladder)
18039 {
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1484257 times.
1484257 if(toogam) return true;
18041
3/4
✓ Branch 0 taken 718698 times.
✓ Branch 1 taken 765559 times.
✓ Branch 2 taken 718698 times.
✗ Branch 3 not taken.
1484257 if(!(dx || dy)) return true;
18042 1484257 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
18043 1484257 zfix rx = x+15.9999_zf, ry = y+15.9999_zf; //right/bottom
18044 1484257 zfix wid = 16, hei = bigHitbox ? 16 : 8;
18045
7/14
✓ Branch 0 taken 1415468 times.
✓ Branch 1 taken 68789 times.
✓ Branch 2 taken 336765 times.
✓ Branch 3 taken 1078703 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 336635 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 130 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1484257 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18046 return false;
18047
18048 1484257 bool nosolid = true;
18049
18050 1484257 bool ret = true;
18051
18052
3/4
✓ Branch 0 taken 765559 times.
✓ Branch 1 taken 718698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 765559 times.
1484257 if(dx && !dy)
18053 {
18054
2/2
✓ Branch 0 taken 355607 times.
✓ Branch 1 taken 409952 times.
765559 if(dx < 0)
18055 {
18056 355607 zfix mx = bx+dx;
18057
2/2
✓ Branch 0 taken 355607 times.
✓ Branch 1 taken 237608 times.
593215 for(zfix ty = 0; by+ty < ry; ty += 8)
18058 {
18059
2/2
✓ Branch 0 taken 211021 times.
✓ Branch 1 taken 144586 times.
355607 if(scr_walkflag(mx, by+ty, left, kb, canladder))
18060 {
18061
2/2
✓ Branch 0 taken 26587 times.
✓ Branch 1 taken 117999 times.
144586 if (canladder) ret = false;
18062 else
18063 {
18064 117999 return false;
18065 }
18066 26587 }
18067 237608 }
18068
2/2
✓ Branch 0 taken 48847 times.
✓ Branch 1 taken 188761 times.
237608 if(scr_walkflag(mx, ry, left, kb, canladder))
18069 48847 return false;
18070
2/2
✓ Branch 0 taken 184717 times.
✓ Branch 1 taken 4044 times.
188761 if (!ret) return false;
18071
2/4
✓ Branch 0 taken 184717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184717 times.
✗ Branch 3 not taken.
184717 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
18072 return false;
18073 184717 }
18074 else
18075 {
18076 409952 zfix mx = rx+dx;
18077 409952 int lx = mx-hit_width+1;
18078
2/2
✓ Branch 0 taken 409952 times.
✓ Branch 1 taken 275659 times.
685611 for(zfix ty = 0; by+ty < ry; ty += 8)
18079 {
18080
2/2
✓ Branch 0 taken 239222 times.
✓ Branch 1 taken 170730 times.
409952 if(scr_walkflag(mx, by+ty, right, kb, canladder))
18081 {
18082
2/2
✓ Branch 0 taken 36437 times.
✓ Branch 1 taken 134293 times.
170730 if (canladder) ret = false;
18083 else
18084 {
18085 134293 return false;
18086 }
18087 36437 }
18088 275659 }
18089
2/2
✓ Branch 0 taken 73418 times.
✓ Branch 1 taken 202241 times.
275659 if(scr_walkflag(mx, ry, right, kb, canladder))
18090 73418 return false;
18091
2/2
✓ Branch 0 taken 194787 times.
✓ Branch 1 taken 7454 times.
202241 if (!ret) return false;
18092
2/4
✓ Branch 0 taken 194787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194787 times.
✗ Branch 3 not taken.
194787 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
18093 return false;
18094 }
18095 379504 }
18096
2/4
✓ Branch 0 taken 718698 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 718698 times.
718698 else if(dy && !dx)
18097 {
18098
2/2
✓ Branch 0 taken 345979 times.
✓ Branch 1 taken 372719 times.
718698 if(dy < 0)
18099 {
18100 345979 zfix my = by+dy;
18101
2/2
✓ Branch 0 taken 599676 times.
✓ Branch 1 taken 234232 times.
833908 for(zfix tx = 0; bx+tx < rx; tx += 8)
18102 {
18103
2/2
✓ Branch 0 taken 368598 times.
✓ Branch 1 taken 231078 times.
599676 if(scr_walkflag(bx+tx, my, up, kb, canladder))
18104 {
18105
2/2
✓ Branch 0 taken 119331 times.
✓ Branch 1 taken 111747 times.
231078 if (canladder) ret = false;
18106 else
18107 {
18108 111747 return false;
18109 }
18110 119331 }
18111 487929 }
18112
2/2
✓ Branch 0 taken 76733 times.
✓ Branch 1 taken 157499 times.
234232 if(scr_walkflag(rx, my, up, kb, canladder))
18113 76733 return false;
18114
2/2
✓ Branch 0 taken 141713 times.
✓ Branch 1 taken 15786 times.
157499 if (!ret) return false;
18115
2/4
✓ Branch 0 taken 141713 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141713 times.
✗ Branch 3 not taken.
141713 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
18116 return false;
18117 141713 }
18118 else
18119 {
18120 372719 zfix my = ry+dy;
18121 372719 int ly = my-hit_height+1;
18122
2/2
✓ Branch 0 taken 613203 times.
✓ Branch 1 taken 212533 times.
825736 for(zfix tx = 0; bx+tx < rx; tx += 8)
18123 {
18124
2/2
✓ Branch 0 taken 403846 times.
✓ Branch 1 taken 209357 times.
613203 if(scr_walkflag(bx+tx, my, down, kb, canladder))
18125 {
18126
2/2
✓ Branch 0 taken 49171 times.
✓ Branch 1 taken 160186 times.
209357 if (canladder) ret = false;
18127 else
18128 {
18129 160186 return false;
18130 }
18131 49171 }
18132 453017 }
18133
2/2
✓ Branch 0 taken 59778 times.
✓ Branch 1 taken 152755 times.
212533 if(scr_walkflag(rx, my, down, kb, canladder))
18134 59778 return false;
18135
2/2
✓ Branch 0 taken 145940 times.
✓ Branch 1 taken 6815 times.
152755 if (!ret) return false;
18136
2/4
✓ Branch 0 taken 145940 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145940 times.
145940 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
18137 return false;
18138 }
18139 287653 }
18140 else //! Untested, and currently unused.
18141 {
18142 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
18143 }
18144 667157 return ret;
18145 1484257 }
18146 444360 bool handle_movestate(std::function<bool()> proc)
18147 {
18148 444360 zfix ox = Hero.x, oy = Hero.y;
18149 444360 auto oladderx = Hero.ladderx;
18150 444360 auto oladdery = Hero.laddery;
18151 444360 auto oladderdir = Hero.ladderdir;
18152 444360 auto oladderstart = Hero.ladderstart;
18153
18154 444360 bool ret = proc();
18155
18156 444360 Hero.x = ox;
18157 444360 Hero.y = oy;
18158 444360 Hero.ladderx = oladderx;
18159 444360 Hero.laddery = oladdery;
18160 444360 Hero.ladderdir = oladderdir;
18161 444360 Hero.ladderstart = oladderstart;
18162
18163 444360 return ret;
18164 }
18165
18166 70 zfix handle_movestate_zfix(std::function<zfix()> proc)
18167 {
18168 70 zfix ox = Hero.x, oy = Hero.y;
18169 70 auto oladderx = Hero.ladderx;
18170 70 auto oladdery = Hero.laddery;
18171 70 auto oladderdir = Hero.ladderdir;
18172 70 auto oladderstart = Hero.ladderstart;
18173
18174 70 zfix ret = proc();
18175
18176 70 Hero.x = ox;
18177 70 Hero.y = oy;
18178 70 Hero.ladderx = oladderx;
18179 70 Hero.laddery = oladdery;
18180 70 Hero.ladderdir = oladderdir;
18181 70 Hero.ladderstart = oladderstart;
18182
18183 70 return ret;
18184 }
18185
18186 52726 optional<zfix> HeroClass::get_solid_coord(zfix tx, zfix ty, byte dir, byte mdir, bool kb, zfix earlyterm, bool doladder)
18187 {
18188 52726 zfix tmp;
18189
4/5
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9249 times.
✓ Branch 3 taken 20746 times.
✓ Branch 4 taken 18426 times.
52726 switch(dir)
18190 {
18191 default:
18192 case up:
18193
2/4
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4305 times.
✗ Branch 3 not taken.
78542 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18194 {
18195 74237 int laddercheck = -1;
18196
2/2
✓ Branch 0 taken 36594 times.
✓ Branch 1 taken 37643 times.
74237 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18197 {
18198 36594 retval = ty;
18199 36594 return BSEARCH_CONTINUE_UP;
18200 }
18201
2/4
✓ Branch 0 taken 37643 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37643 times.
37643 else if(doladder && laddercheck > 0)
18202 {
18203 retval = ty;
18204 return BSEARCH_CONTINUE_UP;
18205 }
18206 37643 else return BSEARCH_CONTINUE_DOWN;
18207
1/2
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
78542 }, -999);
18208
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 3900 times.
4305 if(tmp > -999)
18209 3900 tmp -= 15.9999_zf;
18210 4305 break;
18211 case down:
18212
2/4
✓ Branch 0 taken 9249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9249 times.
✗ Branch 3 not taken.
171198 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18213 {
18214 161949 int laddercheck = -1;
18215
2/2
✓ Branch 0 taken 68594 times.
✓ Branch 1 taken 93355 times.
161949 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18216 {
18217 68594 retval = ty;
18218 68594 return BSEARCH_CONTINUE_DOWN;
18219 }
18220
2/4
✓ Branch 0 taken 93355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93355 times.
93355 else if(doladder && laddercheck > 0)
18221 {
18222 retval = ty;
18223 return BSEARCH_CONTINUE_DOWN;
18224 }
18225 93355 else return BSEARCH_CONTINUE_UP;
18226
1/2
✓ Branch 0 taken 9249 times.
✗ Branch 1 not taken.
171198 }, -999);
18227
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 8921 times.
9249 if(tmp > -999)
18228 8921 tmp -= (bigHitbox?0:8);
18229 9249 break;
18230 case left:
18231
2/4
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20746 times.
✗ Branch 3 not taken.
388122 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18232 {
18233 367376 int laddercheck = -1;
18234
2/2
✓ Branch 0 taken 49393 times.
✓ Branch 1 taken 317983 times.
367376 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18235 {
18236 49393 retval = tx;
18237 49393 return BSEARCH_CONTINUE_UP;
18238 }
18239
2/4
✓ Branch 0 taken 317983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 317983 times.
317983 else if(doladder && laddercheck > 0)
18240 {
18241 retval = tx;
18242 return BSEARCH_CONTINUE_UP;
18243 }
18244 317983 else return BSEARCH_CONTINUE_DOWN;
18245
1/2
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
388122 }, -999);
18246
2/2
✓ Branch 0 taken 15276 times.
✓ Branch 1 taken 5470 times.
20746 if(tmp > -999)
18247 5470 tmp -= 15.9999_zf;
18248 20746 break;
18249 case right:
18250
2/4
✓ Branch 0 taken 18426 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18426 times.
✗ Branch 3 not taken.
346191 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18251 {
18252 327765 int laddercheck = -1;
18253
2/2
✓ Branch 0 taken 38349 times.
✓ Branch 1 taken 289416 times.
327765 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18254 {
18255 38349 retval = tx;
18256 38349 return BSEARCH_CONTINUE_DOWN;
18257 }
18258
2/4
✓ Branch 0 taken 289416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289416 times.
289416 else if(doladder && laddercheck > 0)
18259 {
18260 retval = tx;
18261 return BSEARCH_CONTINUE_DOWN;
18262 }
18263 289416 else return BSEARCH_CONTINUE_UP;
18264
1/2
✓ Branch 0 taken 18426 times.
✗ Branch 1 not taken.
346191 }, -999);
18265 18426 break;
18266 }
18267
2/2
✓ Branch 0 taken 29922 times.
✓ Branch 1 taken 22804 times.
52726 if(tmp > -999)
18268 {
18269 22804 zfix tx2(x), ty2(y);
18270 22804 zfix dx, dy;
18271
4/5
✓ Branch 0 taken 3900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5470 times.
✓ Branch 3 taken 4513 times.
✓ Branch 4 taken 8921 times.
22804 switch(dir)
18272 {
18273 case left:
18274 5470 tx2 = tmp;
18275 5470 break;
18276 case right:
18277 4513 tx2 = tmp;
18278 4513 break;
18279 default:
18280 case up:
18281 3900 ty2 = tmp;
18282 3900 break;
18283 case down:
18284 8921 ty2 = tmp;
18285 8921 break;
18286 }
18287
4/5
✓ Branch 0 taken 4894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4027 times.
✓ Branch 3 taken 8794 times.
✓ Branch 4 taken 5089 times.
22804 switch(mdir)
18288 {
18289 case left:
18290 4027 dx = -0.0001_zf;
18291 4027 break;
18292 case right:
18293 8794 dx = 0.0001_zf;
18294 8794 break;
18295 default:
18296 case up:
18297 4894 dy = -0.0001_zf;
18298 4894 break;
18299 case down:
18300 5089 dy = 0.0001_zf;
18301 5089 break;
18302 }
18303 22804 zfix oldx(x), oldy(y);
18304 22804 x = tx2;
18305 22804 y = ty2;
18306 22804 int laddercheck = -1;
18307 22804 bool valid = scr_canmove(dx, dy, kb, true, &laddercheck);
18308
1/2
✓ Branch 0 taken 22804 times.
✗ Branch 1 not taken.
22804 if (laddercheck > 0) valid = true;
18309 22804 x = oldx;
18310 22804 y = oldy;
18311
2/2
✓ Branch 0 taken 22754 times.
✓ Branch 1 taken 50 times.
22804 if(valid)
18312 22754 return tmp;
18313 50 }
18314 29972 return std::nullopt;
18315 52726 }
18316
18317 727656 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
18318 {
18319 727656 bool ret = true;
18320 727656 int ladderstuff = -1;
18321
8/10
✓ Branch 0 taken 703995 times.
✓ Branch 1 taken 23661 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 703234 times.
✓ Branch 4 taken 559 times.
✓ Branch 5 taken 202 times.
✓ Branch 6 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 559 times.
727656 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
18322
2/2
✓ Branch 0 taken 727097 times.
✓ Branch 1 taken 559 times.
727656 if(sv)
18323 559 dy = 0;
18324
4/4
✓ Branch 0 taken 426002 times.
✓ Branch 1 taken 301654 times.
✓ Branch 2 taken 358718 times.
✓ Branch 3 taken 67284 times.
727656 if(dx && dy)
18325 67284 shove = false;
18326 727656 bool checkladder = dy < 0;
18327
18328 727656 const int scl = 2;
18329
4/4
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 727712 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 727656 times.
727886 while(abs(dx) > scl || abs(dy) > scl)
18330 {
18331
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 56 times.
230 if(abs(dx) > abs(dy))
18332 {
18333 174 int32_t tdx = dx.sign() * scl;
18334
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1 times.
174 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
18335 173 dx -= tdx;
18336 else
18337 {
18338
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
18339 1 dx = tdx;
18340 1 ret = false;
18341 }
18342 174 }
18343 else
18344 {
18345 56 int32_t tdy = dy.sign() * scl;
18346
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
18347 56 dy -= tdy;
18348 else
18349 {
18350 if(earlyret) return false;
18351 dy = tdy;
18352 ret = false;
18353 }
18354 }
18355 }
18356
18357
10/12
✓ Branch 0 taken 283156 times.
✓ Branch 1 taken 444500 times.
✓ Branch 2 taken 29604 times.
✓ Branch 3 taken 253552 times.
✓ Branch 4 taken 29604 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 632 times.
✓ Branch 7 taken 28972 times.
✓ Branch 8 taken 27732 times.
✓ Branch 9 taken 1240 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 27732 times.
727656 bool skipdmg = earlyret || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || hclk || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS));
18358
2/2
✓ Branch 0 taken 301654 times.
✓ Branch 1 taken 426002 times.
727656 if(dx)
18359 {
18360
2/2
✓ Branch 0 taken 355678 times.
✓ Branch 1 taken 70324 times.
426002 if(scr_canmove(dx, 0, kb, ign_sv, &ladderstuff))
18361 {
18362
1/2
✓ Branch 0 taken 355678 times.
✗ Branch 1 not taken.
355678 if (ladderstuff == 1)
18363 {
18364 zfix tx = (dx < 0 ? (x+dx) : (x+8+dx));
18365 zfix tx2 = (dx < 0 ? 15 : 0);
18366 zfix tx3 = (dx < 0 ? -8 : 8);
18367 ladderx = TRUNCATE_HALF_TILE(tx.getInt());
18368 laddery = y.getTrunc();
18369 if (((iswaterex_z3(MAPCOMBO(ladderx+tx2,y+9), -1, ladderx+tx2,y+9) != 0) || getpitfall(ladderx+tx2,y+9))
18370 && ((iswaterex_z3(MAPCOMBO(ladderx+tx2,y+15), -1, ladderx+tx2,y+15) != 0) || getpitfall(ladderx+tx2,y+15)))
18371 {
18372 ladderdir = left;
18373 ladderstart = dir;
18374 }
18375 else if (((iswaterex_z3(MAPCOMBO(ladderx+tx2+tx3,y+9), -1, ladderx+tx2+tx3,y+9) != 0) || getpitfall(ladderx+tx2+tx3,y+9))
18376 && ((iswaterex_z3(MAPCOMBO(ladderx+tx2+tx3,y+15), -1, ladderx+tx2+tx3,y+15) != 0) || getpitfall(ladderx+tx2+tx3,y+15)))
18377 {
18378 ladderx = TRUNCATE_HALF_TILE(tx.getInt()+tx3.getInt());
18379 ladderdir = left;
18380 ladderstart = dir;
18381 }
18382 else
18383 {
18384 ladderx = 0;
18385 laddery = 0;
18386 }
18387 }
18388
1/2
✓ Branch 0 taken 355678 times.
✗ Branch 1 not taken.
355678 if (ladderstuff > 0) ladderstuff = 0;
18389 355678 x += dx;
18390 355678 }
18391 else
18392 {
18393 70324 bool stopped = true;
18394 70324 bool shoved = false;
18395
2/2
✓ Branch 0 taken 11024 times.
✓ Branch 1 taken 59300 times.
70324 if(shove)
18396 {
18397
2/2
✓ Branch 0 taken 24461 times.
✓ Branch 1 taken 34839 times.
59300 zfix tx = (dx < 0 ? (x-4) : (x+20));
18398 59300 int v=bigHitbox?0:8;
18399 59300 zfix ly = y+v;
18400 59300 zfix ry = y+15.9999_zf;
18401 59300 zfix ly2 = y+v+6;
18402 59300 zfix ry2 = y+9.9999_zf;
18403 59300 auto mdir = GET_XDIR(dx);
18404 59300 int laddershove = -1;
18405 59300 int ladderhit = 0;
18406 59300 bool onladder = (ladderx + laddery);
18407 59300 bool hit_top = scr_walkflag(tx,ly,mdir,false, &laddershove);
18408
1/2
✓ Branch 0 taken 59300 times.
✗ Branch 1 not taken.
59300 if (laddershove > 0)
18409 {
18410 hit_top = false;
18411 ladderhit += 1;
18412 }
18413 59300 laddershove = -1;
18414 59300 bool hit_bottom = scr_walkflag(tx,ry,mdir,false, &laddershove);
18415
1/2
✓ Branch 0 taken 59300 times.
✗ Branch 1 not taken.
59300 if (laddershove > 0)
18416 {
18417 hit_bottom = false;
18418 ladderhit += 2;
18419 }
18420 59300 laddershove = -1;
18421 59300 bool hit_top2 = scr_walkflag(tx,ly2,mdir,false);
18422 59300 bool hit_bottom2 = scr_walkflag(tx,ry2,mdir,false);
18423
3/4
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 54878 times.
✓ Branch 2 taken 4422 times.
✗ Branch 3 not taken.
59300 if (!hit_top && ladderhit == 2)
18424 {
18425 hit_bottom = true;
18426 }
18427
3/4
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 49934 times.
✓ Branch 2 taken 9366 times.
✗ Branch 3 not taken.
59300 if (!hit_bottom && ladderhit == 1)
18428 {
18429 hit_top = true;
18430 }
18431
2/2
✓ Branch 0 taken 45746 times.
✓ Branch 1 taken 13554 times.
59300 if(hit_top!=hit_bottom)
18432 {
18433
2/2
✓ Branch 0 taken 4305 times.
✓ Branch 1 taken 9249 times.
13554 if(hit_bottom) //shove up
18434 {
18435
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4305 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4305 if (onladder && (ladderdir == left || ladderdir == right) && !hit_bottom2)
18436 {
18437 y -= 1_zf;
18438 shoved = true;
18439 }
18440
5/6
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4305 times.
4305 else if(skipdmg || !checkdamagecombos(tx,get_qr(qr_SENSITIVE_SOLID_DAMAGE)?int32_t(y+15):(v+bigHitbox?11:4)))
18441 {
18442
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 3896 times.
4305 if(optional<zfix> ty = get_solid_coord(tx,ry,up,mdir,false,ry-shove_offset, (ladderhit != 2)))
18443 {
18444
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 3206 times.
3896 zfix dy = zc_max(-1_zf,*ty-y);
18445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3896 times.
3896 if((shoved = dy))
18446 3896 movexy(0, dy, kb, true, false, false);
18447 3896 }
18448 4305 }
18449 4305 }
18450 else //shove down
18451 {
18452
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9249 if (onladder && (ladderdir == left || ladderdir == right) && !hit_top2)
18453 {
18454 y += 1_zf;
18455 shoved = true;
18456 }
18457
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9249 else if(skipdmg || !checkdamagecombos(tx,v+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
18458 {
18459
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 8921 times.
9249 if(optional<zfix> ty = get_solid_coord(tx,ly,down,mdir,false,ly+shove_offset, (ladderhit != 1)))
18460 {
18461
2/2
✓ Branch 0 taken 8287 times.
✓ Branch 1 taken 634 times.
8921 zfix dy = zc_min(1_zf,*ty-y);
18462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8921 times.
8921 if((shoved = dy))
18463 8921 movexy(0, dy, kb, true, false, false);
18464 8921 }
18465 9249 }
18466 }
18467
18468
4/4
✓ Branch 0 taken 12817 times.
✓ Branch 1 taken 737 times.
✓ Branch 2 taken 11378 times.
✓ Branch 3 taken 1439 times.
13554 if(shoved && scr_canmove(dx, 0, kb, ign_sv))
18469 {
18470 1439 x += dx;
18471 1439 stopped = false;
18472 1439 }
18473 13554 }
18474 59300 }
18475
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 68885 times.
70324 if(stopped)
18476 {
18477
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 68885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
68885 if (ladderstuff > 0 && !shoved)
18478 {
18479 zfix tx = (dx < 0 ? (x-12) : (x+20));
18480 ladderx = TRUNCATE_HALF_TILE(tx.getInt());
18481 laddery = y.getTrunc();
18482 ladderdir = left;
18483 ladderstart = dir;
18484 x += dx;
18485 ladderstuff = 0;
18486 }
18487
2/2
✓ Branch 0 taken 48997 times.
✓ Branch 1 taken 19888 times.
68885 else if(earlyret)
18488 {
18489 48997 ret = false;
18490 48997 }
18491 else
18492 {
18493 19888 ret = false;
18494 19888 int xsign = dx.sign();
18495
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 18028 times.
19888 if(abs(dx) > 1)
18496 {
18497
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 18028 times.
18497 while(scr_canmove(xsign, 0, kb, ign_sv))
18498 {
18499 469 x += xsign;
18500 469 dx -= xsign;
18501 }
18502 18028 }
18503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19888 times.
19888 if(dx)
18504 {
18505 19888 dx.doDecBound(0,-9999, 0,9999);
18506
3/6
✓ Branch 0 taken 19888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19888 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19888 times.
✗ Branch 5 not taken.
315296 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
18507
2/2
✓ Branch 0 taken 9087 times.
✓ Branch 1 taken 286321 times.
295408 if(scr_canmove(val, 0, kb, ign_sv))
18508 {
18509 9087 retval = val;
18510 9087 return BSEARCH_CONTINUE_AWAY0;
18511 }
18512 286321 else return BSEARCH_CONTINUE_TOWARD0;
18513 295408 });
18514 19888 x += dx;
18515 19888 }
18516 }
18517 68885 }
18518 }
18519 426002 }
18520 727656 ladderstuff = -1;
18521
2/2
✓ Branch 0 taken 359680 times.
✓ Branch 1 taken 367976 times.
727656 if(dy)
18522 {
18523
2/2
✓ Branch 0 taken 264096 times.
✓ Branch 1 taken 103880 times.
367976 if(scr_canmove(0, dy, kb, ign_sv, &ladderstuff))
18524 {
18525
1/2
✓ Branch 0 taken 264096 times.
✗ Branch 1 not taken.
264096 if (ladderstuff == 1)
18526 {
18527 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)+dy) : (y+8+dy));
18528 zfix ty2 = (dy < 0 ? 15 : 0);
18529 zfix ty3 = (dy < 0 ? -8 : 8);
18530
18531 ladderx = x.getTrunc();
18532 laddery = TRUNCATE_HALF_TILE(ty.getInt());
18533 if (((iswaterex_z3(MAPCOMBO(x+4,laddery+ty2), -1, x+4,laddery+ty2) != 0) || getpitfall(x+4,laddery+ty2))
18534 && ((iswaterex_z3(MAPCOMBO(x+11,laddery+ty2), -1, x+11,laddery+ty2) != 0) || getpitfall(x+11,laddery+ty2)))
18535 {
18536 ladderdir = up;
18537 ladderstart = dir;
18538 }
18539 else if (((iswaterex_z3(MAPCOMBO(x+4,laddery+ty2+ty3), -1, x+4,laddery+ty2+ty3) != 0) || getpitfall(x+4,laddery+ty2+ty3))
18540 && ((iswaterex_z3(MAPCOMBO(x+11,laddery+ty2+ty3), -1, x+11,laddery+ty2+ty3) != 0) || getpitfall(x+11,laddery+ty2+ty3)))
18541 {
18542 laddery = TRUNCATE_HALF_TILE(ty.getInt() + ty3.getInt());
18543 ladderdir = up;
18544 ladderstart = dir;
18545 }
18546 else
18547 {
18548 ladderx = 0;
18549 laddery = 0;
18550 }
18551 }
18552
1/2
✓ Branch 0 taken 264096 times.
✗ Branch 1 not taken.
264096 if (ladderstuff > 0) ladderstuff = 0;
18553 264096 y += dy;
18554 264096 }
18555 else
18556 {
18557 103880 bool stopped = true;
18558 103880 bool shoved = false;
18559
2/2
✓ Branch 0 taken 11975 times.
✓ Branch 1 taken 91905 times.
103880 if(shove)
18560 {
18561
2/2
✓ Branch 0 taken 66553 times.
✓ Branch 1 taken 25352 times.
91905 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-4) : (y+20));
18562 91905 zfix lx = x;
18563 91905 zfix rx = x+15.9999_zf;
18564 91905 zfix lx2 = x+6;
18565 91905 zfix rx2 = x+9.9999_zf;
18566 91905 auto mdir = GET_YDIR(dy);
18567 91905 int laddershove = -1;
18568 91905 int ladderhit = 0;
18569 91905 bool onladder = (ladderx + laddery);
18570 91905 bool hit_left = scr_walkflag(lx,ty,mdir,false, &laddershove);
18571
1/2
✓ Branch 0 taken 91905 times.
✗ Branch 1 not taken.
91905 if (laddershove > 0)
18572 {
18573 hit_left = false;
18574 ladderhit += 1;
18575 }
18576 91905 laddershove = -1;
18577 91905 bool hit_right = scr_walkflag(rx,ty,mdir,false, &laddershove);
18578
1/2
✓ Branch 0 taken 91905 times.
✗ Branch 1 not taken.
91905 if (laddershove > 0)
18579 {
18580 hit_right = false;
18581 ladderhit += 2;
18582 }
18583 91905 bool hit_left2 = scr_walkflag(lx2,ty,mdir,false);
18584 91905 bool hit_right2 = scr_walkflag(rx2,ty,mdir,false);
18585 91905 laddershove = -1;
18586
3/4
✓ Branch 0 taken 20920 times.
✓ Branch 1 taken 70985 times.
✓ Branch 2 taken 20920 times.
✗ Branch 3 not taken.
91905 if (!hit_left && ladderhit == 2)
18587 {
18588 hit_right = true;
18589 }
18590
3/4
✓ Branch 0 taken 18600 times.
✓ Branch 1 taken 73305 times.
✓ Branch 2 taken 18600 times.
✗ Branch 3 not taken.
91905 if (!hit_right && ladderhit == 1)
18591 {
18592 hit_left = true;
18593 }
18594
2/2
✓ Branch 0 taken 52733 times.
✓ Branch 1 taken 39172 times.
91905 if(hit_left!=hit_right)
18595 {
18596
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 18426 times.
39172 if(hit_right) //shove left
18597 {
18598
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20746 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20746 if (onladder && ladderdir <= down && !hit_right2)
18599 {
18600 x -= 1_zf;
18601 shoved = true;
18602 }
18603
3/4
✓ Branch 0 taken 20734 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20746 times.
20746 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),ty))
18604 {
18605
2/2
✓ Branch 0 taken 15276 times.
✓ Branch 1 taken 5470 times.
20746 if(optional<zfix> tx = get_solid_coord(rx,ty,left,mdir,false,rx-shove_offset, (ladderhit != 2)))
18606 {
18607
2/2
✓ Branch 0 taken 4400 times.
✓ Branch 1 taken 1070 times.
5470 zfix dx = zc_max(-1_zf,*tx-x);
18608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5470 times.
5470 if((shoved = dx))
18609 5470 movexy(dx, 0, kb, true, false, false);
18610 5470 }
18611 20746 }
18612 20746 }
18613 else //shove right
18614 {
18615
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18426 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18426 if (onladder && ladderdir <= down && !hit_left2)
18616 {
18617 x += 1_zf;
18618 shoved = true;
18619 }
18620
3/4
✓ Branch 0 taken 18396 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18426 times.
18426 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),ty))
18621 {
18622
2/2
✓ Branch 0 taken 13959 times.
✓ Branch 1 taken 4467 times.
18426 if(optional<zfix> tx = get_solid_coord(lx,ty,right,mdir,false,lx+shove_offset, (ladderhit != 1)))
18623 {
18624
2/2
✓ Branch 0 taken 1675 times.
✓ Branch 1 taken 2792 times.
4467 zfix dx = zc_min(1_zf,*tx-x);
18625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4467 times.
4467 if((shoved = dx))
18626 4467 movexy(dx, 0, kb, true, false, false);
18627 4467 }
18628 18426 }
18629 }
18630
18631
4/4
✓ Branch 0 taken 9937 times.
✓ Branch 1 taken 29235 times.
✓ Branch 2 taken 6924 times.
✓ Branch 3 taken 3013 times.
39172 if(shoved && scr_canmove(0, dy, kb, ign_sv))
18632 {
18633 3013 y += dy;
18634 3013 stopped = false;
18635 3013 }
18636 39172 }
18637 91905 }
18638
2/2
✓ Branch 0 taken 3013 times.
✓ Branch 1 taken 100867 times.
103880 if(stopped)
18639 {
18640
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 100867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100867 if (ladderstuff > 0 && !shoved)
18641 {
18642 zfix ty = (dy < 0 ? (y-(bigHitbox?12:4)) : (y+20));
18643 ladderx = x.getTrunc();
18644 laddery = TRUNCATE_HALF_TILE(ty.getInt());
18645 ladderdir = up;
18646 ladderstart = dir;
18647 y += dy;
18648 ladderstuff = 0;
18649 }
18650 else
18651 {
18652
2/2
✓ Branch 0 taken 79867 times.
✓ Branch 1 taken 21000 times.
100867 if(earlyret) return false;
18653 21000 ret = false;
18654 21000 int ysign = dy.sign();
18655
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 18355 times.
21000 if(abs(dy) > 1)
18656 {
18657
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 18355 times.
18699 while(scr_canmove(0, ysign, kb, ign_sv))
18658 {
18659 344 y += ysign;
18660 344 dy -= ysign;
18661 }
18662 18355 }
18663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21000 times.
21000 if(dy)
18664 {
18665 21000 dy.doDecBound(0,-9999, 0,9999);
18666
3/6
✓ Branch 0 taken 21000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21000 times.
✗ Branch 5 not taken.
333047 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
18667
2/2
✓ Branch 0 taken 10207 times.
✓ Branch 1 taken 301840 times.
312047 if(scr_canmove(0, val, kb, ign_sv))
18668 {
18669 10207 retval = val;
18670 10207 return BSEARCH_CONTINUE_AWAY0;
18671 }
18672 301840 else return BSEARCH_CONTINUE_TOWARD0;
18673 312047 });
18674 21000 y += dy;
18675 21000 }
18676 }
18677 21000 }
18678 }
18679 288109 }
18680
18681
2/2
✓ Branch 0 taken 364633 times.
✓ Branch 1 taken 283156 times.
647789 if(earlyret)
18682 364633 return ret;
18683
7/10
✓ Branch 0 taken 65586 times.
✓ Branch 1 taken 217570 times.
✓ Branch 2 taken 61720 times.
✓ Branch 3 taken 3866 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 61590 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 130 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
283156 if(dy < 0 && !ign_sv && sideview_mode() && IsSideSwim() && checkladder)
18684 {
18685 if(!iswaterex_z3(MAPCOMBO(x, y+(bigHitbox?0:8)-2), -1, x, y+(bigHitbox?0:8) - 2, true, false)
18686 && !canSideviewLadderRemote(x, y-4) && scr_canmove(0, -2, kb, true) && (y+(bigHitbox?0:8) - 4) > 0)
18687 {
18688 if (game->get_sideswim_jump() != 0)
18689 {
18690 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
18691 sfx(WAV_ZN1SPLASH,(int32_t)x);
18692 hopclk = 0;
18693 if (charging || spins) action = attacking;
18694 else action = none;
18695 }
18696 else
18697 {
18698 movexy(0,-1*dy,false,false,false);
18699 }
18700 }
18701 }
18702 283156 return ret;
18703 727656 }
18704 3596 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
18705 {
18706
1/2
✓ Branch 0 taken 3596 times.
✗ Branch 1 not taken.
7192 return handle_movestate([&]()
18707 {
18708 3596 return movexy(dx,dy,kb,ign_sv,shove,true);
18709 });
18710 }
18711 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18712 {
18713 double v = degrees.getFloat() * PI / 180.0;
18714 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
18715 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
18716 }
18717 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
18718 {
18719 return handle_movestate([&]()
18720 {
18721 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
18722 });
18723 }
18724 440764 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18725 {
18726
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 440762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
440764 static const zfix diagrate = zslongToFix(7071);
18727
6/13
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 440764 times.
✓ Branch 4 taken 128017 times.
✓ Branch 5 taken 84306 times.
✓ Branch 6 taken 110138 times.
✓ Branch 7 taken 118303 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
440764 switch(NORMAL_DIR(dir))
18728 {
18729 case up:
18730 128017 return movexy(0, -px, kb, ign_sv, shove, earlyret);
18731 case down:
18732 84306 return movexy(0, px, kb, ign_sv, shove, earlyret);
18733 case left:
18734 110138 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
18735 case right:
18736 118303 return movexy(px, 0, kb, ign_sv, shove, earlyret);
18737 case r_up:
18738 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18739 case r_down:
18740 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18741 case l_up:
18742 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18743 case l_down:
18744 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18745 }
18746 return false;
18747 440764 }
18748 440764 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
18749 {
18750
1/2
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
881528 return handle_movestate([&]()
18751 {
18752 440764 return moveDir(dir,px,kb,ign_sv,shove,true);
18753 });
18754 }
18755
18756
18757 402696 bool HeroClass::premove()
18758 {
18759
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 402352 times.
402696 if(lstunclock) return false;
18760
4/4
✓ Branch 0 taken 3376 times.
✓ Branch 1 taken 398976 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 3267 times.
402352 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
18761 398976 int32_t xoff=x.getInt()&7;
18762 398976 int32_t yoff=y.getInt()&7;
18763
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 398976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
398976 if(NO_GRIDLOCK)
18764 {
18765 398976 xoff = 0;
18766 398976 yoff = 0;
18767 398976 }
18768 398976 int32_t push=pushing;
18769 398976 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
18770 398976 int32_t flippers_id = current_item_id(itype_flippers);
18771 398976 itemdata const& itm = itemsbuf[flippers_id];
18772 398976 byte intbtn = byte(itm.misc3&0xFF);
18773 398976 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
18774 398976 bool eatdive = false;
18775
2/2
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 398565 times.
398976 if(diveclk>0)
18776 {
18777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 411 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
411 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
18778 411 --diveclk;
18779
4/8
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 326 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
411 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
18780 {
18781 diveclk = itemsbuf[flippers_id].misc2;
18782 eatdive = true;
18783 }
18784 411 }
18785
4/4
✓ Branch 0 taken 6251 times.
✓ Branch 1 taken 392314 times.
✓ Branch 2 taken 6240 times.
✓ Branch 3 taken 11 times.
398565 else if(action == swimming && dive_pressed)
18786 {
18787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
18788 11 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
18789
18790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(global_diving==screen_diving)
18791 {
18792
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
18793 11 eatdive = true;
18794 11 }
18795 11 }
18796
2/2
✓ Branch 0 taken 398965 times.
✓ Branch 1 taken 11 times.
398976 if(eatdive)
18797 11 getIntBtnInput(intbtn, true, true, false, false, false);
18798
18799
1/2
✓ Branch 0 taken 398976 times.
✗ Branch 1 not taken.
398976 if(action==rafting)
18800 {
18801 do_rafting();
18802
18803 if(action==rafting)
18804 {
18805 return false;
18806 }
18807
18808
18809 set_respawn_point();
18810 trySideviewLadder();
18811 }
18812
18813 398976 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
18814 398976 int32_t btnwpn = -1;
18815
18816 //&0xFFF removes the "bow & arrows" bitmask
18817 //The Quick Sword is allowed to interrupt attacks.
18818
4/4
✓ Branch 0 taken 388298 times.
✓ Branch 1 taken 10678 times.
✓ Branch 2 taken 261785 times.
✓ Branch 3 taken 126513 times.
398976 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
18819
7/8
✓ Branch 0 taken 364616 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 364550 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 5716 times.
✓ Branch 5 taken 28710 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34426 times.
398976 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
18820 {
18821
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 364364 times.
364550 if(DrunkrBbtn())
18822 {
18823 186 btnwpn=getItemFamily(itemsbuf,Bwpn);
18824
1/2
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
186 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
18825 186 directWpn = directItemB;
18826 186 }
18827
2/2
✓ Branch 0 taken 2102 times.
✓ Branch 1 taken 362262 times.
364364 else if(DrunkrAbtn())
18828 {
18829 2102 btnwpn=getItemFamily(itemsbuf,Awpn);
18830
1/2
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
2102 dowpn = NEG_OR_MASK(Awpn,0xFFF);
18831 2102 directWpn = directItemA;
18832 2102 }
18833
4/4
✓ Branch 0 taken 351949 times.
✓ Branch 1 taken 10313 times.
✓ Branch 2 taken 351826 times.
✓ Branch 3 taken 123 times.
362262 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
18834 {
18835 123 btnwpn=getItemFamily(itemsbuf,Xwpn);
18836
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
18837 123 directWpn = directItemX;
18838 123 }
18839
4/4
✓ Branch 0 taken 351826 times.
✓ Branch 1 taken 10313 times.
✓ Branch 2 taken 351713 times.
✓ Branch 3 taken 113 times.
362139 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
18840 {
18841 113 btnwpn=getItemFamily(itemsbuf,Ywpn);
18842
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
18843 113 directWpn = directItemY;
18844 113 }
18845
18846
1/2
✓ Branch 0 taken 364550 times.
✗ Branch 1 not taken.
364550 if(directWpn >= MAXITEMS) directWpn = -1;
18847
18848 // The Quick Sword only allows repeated sword or wand swings.
18849
3/8
✓ Branch 0 taken 364550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 364550 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 364550 times.
364550 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
18850 btnwpn=-1;
18851 364550 }
18852
18853
2/2
✓ Branch 0 taken 137194 times.
✓ Branch 1 taken 261782 times.
398976 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
18854
10/12
✓ Branch 0 taken 384374 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 381627 times.
✓ Branch 3 taken 2747 times.
✓ Branch 4 taken 250210 times.
✓ Branch 5 taken 131417 times.
✓ Branch 6 taken 250210 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2102 times.
✓ Branch 9 taken 248108 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2102 times.
398976 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
18855 {
18856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
2102 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
18857
2/6
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2102 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
18858 {
18859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2102 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
18860 {
18861 paymagiccost(attackid,true);
18862 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
18863 }
18864 2102 SetAttack();
18865 2102 attack=wSword;
18866
18867 2102 attackclk=0;
18868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
2102 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
18869
18870
2/10
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2102 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
18871 {
18872 if(!checkmagiccost(dowpn))
18873 {
18874 item_error();
18875 }
18876 else
18877 {
18878 //clear the item script stack for a new script
18879 int i = dowpn;
18880 FFCore.reset_script_engine_data(ScriptType::Item, i);
18881 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
18882 did_scripta=true;
18883 }
18884 }
18885 2102 }
18886 else
18887 {
18888 item_error();
18889 }
18890 2102 }
18891 else
18892 {
18893 396874 did_scripta=false;
18894 }
18895
18896
7/10
✓ Branch 0 taken 392314 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 392314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 392314 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 311 times.
✓ Branch 9 taken 392003 times.
398976 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
18897 {
18898
4/4
✓ Branch 0 taken 69003 times.
✓ Branch 1 taken 323000 times.
✓ Branch 2 taken 68995 times.
✓ Branch 3 taken 8 times.
392003 if(DrunkUp() && canSideviewLadder())
18899 {
18900 8 setOnSideviewLadder(true);
18901 8 }
18902
4/4
✓ Branch 0 taken 72790 times.
✓ Branch 1 taken 319205 times.
✓ Branch 2 taken 72789 times.
✓ Branch 3 taken 1 times.
391995 else if(DrunkDown() && canSideviewLadder(true))
18903 {
18904 1 y+=1;
18905 1 setOnSideviewLadder(true);
18906 1 }
18907 392003 }
18908
18909 398976 int32_t wx=x;
18910 398976 int32_t wy=y;
18911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 398976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
398976 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
18912
5/6
✓ Branch 0 taken 288697 times.
✓ Branch 1 taken 110279 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 398656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 320 times.
398976 else if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
18913 {
18914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
320 if((xoff==0)||diagonalMovement)
18915 {
18916
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 130 times.
320 if(DrunkUp()) dir=up;
18917
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 23 times.
320 if(DrunkDown()) dir=down;
18918 320 }
18919
18920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
320 if((yoff==0)||diagonalMovement)
18921 {
18922
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 15 times.
320 if(DrunkLeft()) dir=left;
18923
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 54 times.
320 if(DrunkRight()) dir=right;
18924 320 }
18925 320 }
18926
18927
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 79774 times.
✓ Branch 2 taken 86824 times.
✓ Branch 3 taken 116396 times.
✓ Branch 4 taken 115982 times.
398976 switch(dir)
18928 {
18929 case up:
18930 79774 wy-=16;
18931 79774 break;
18932
18933 case down:
18934 86824 wy+=16;
18935 86824 break;
18936
18937 case left:
18938 116396 wx-=16;
18939 116396 break;
18940
18941 case right:
18942 115982 wx+=16;
18943 115982 break;
18944 }
18945
18946 398976 do_lens();
18947
18948 398976 bool no_jinx = true;
18949
2/2
✓ Branch 0 taken 391036 times.
✓ Branch 1 taken 7940 times.
398976 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
18950
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 391036 times.
398976 if(liftonly)
18951 {
18952
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7940 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7940 if(replay_version_check(38) && btnwpn > -1)
18953 {
18954 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
18955 no_jinx = checkitem_jinx(itmid);
18956 if(no_jinx)
18957 startwpn(itmid);
18958 directWpn = olddirectwpn;
18959 }
18960 7940 }
18961
6/8
✓ Branch 0 taken 384374 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 383956 times.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 418 times.
391036 else if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
18962 {
18963 418 bool paidmagic = false;
18964
5/8
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
418 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
18965 {
18966
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
18967 59 no_jinx = checkitem_jinx(attackid);
18968
3/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
59 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
18969 {
18970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
18971 paymagiccost(attackid,true);
18972 misc_internal_hero_flags |= LF_PAID_WAND_COST;
18973 }
18974 59 SetAttack();
18975 59 attack=wWand;
18976 59 attackclk=0;
18977 59 }
18978 else
18979 {
18980 item_error();
18981 }
18982 59 }
18983
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
359 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
18984 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
18985 {
18986 no_jinx = checkitem_jinx(dowpn);
18987 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
18988 {
18989 item_error();
18990 }
18991 else
18992 {
18993 paymagiccost(dowpn);
18994 paidmagic = true;
18995 SetAttack();
18996 attack=wHammer;
18997 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
18998 attackclk=0;
18999 }
19000 }
19001
4/6
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 308 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
410 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
19002
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
51 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
19003 {
19004 //checkbunny handled where magic cost is paid
19005
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
19006 51 no_jinx = checkitem_jinx(attackid);
19007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(no_jinx)
19008 {
19009 51 SetAttack();
19010 51 attack=wFire;
19011 51 attackclk=0;
19012 51 }
19013 51 }
19014
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
308 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
19015 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
19016 {
19017 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
19018 no_jinx = checkitem_jinx(attackid);
19019 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
19020 {
19021 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
19022 paymagiccost(attackid,true);
19023 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
19024 }
19025 SetAttack();
19026 attack=wCByrna;
19027 attackclk=0;
19028 }
19029 else
19030 {
19031 item_error();
19032 }
19033 }
19034
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
314 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
19035
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
19036 {
19037
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
19038 6 no_jinx = checkitem_jinx(attackid);
19039
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
19040 {
19041 6 paymagiccost(attackid);
19042 6 SetAttack();
19043 6 attack = wBugNet;
19044 6 attackclk = 0;
19045 6 sfx(itemsbuf[attackid].usesound);
19046 6 }
19047 else
19048 {
19049 item_error();
19050 }
19051 6 }
19052 else
19053 {
19054
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
19055 302 no_jinx = checkitem_jinx(itmid);
19056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if(no_jinx)
19057 {
19058 302 paidmagic = startwpn(itmid);
19059
19060
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(paidmagic)
19061 {
19062
5/10
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 302 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 302 times.
302 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
19063 {
19064 ;
19065 }
19066 else
19067 {
19068 302 SetAttack();
19069 302 attackclk=0;
19070 302 attack=none;
19071
19072
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 123 times.
302 if(btnwpn==itype_brang)
19073 {
19074 123 attack=wBrang;
19075 123 }
19076 }
19077 302 }
19078 else
19079 {
19080 // Weapon not started: directWpn should be reset to prev. value.
19081 directWpn = olddirectwpn;
19082 }
19083 302 }
19084 }
19085
19086
3/12
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
418 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19087 {
19088 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
19089 {
19090 item_error();
19091 }
19092 else
19093 {
19094 // Only charge for magic if item's magic cost wasn't already charged
19095 // for the item's main use.
19096 if(!paidmagic && attack!=wWand)
19097 paymagiccost(dowpn);
19098 //clear the item script stack for a new script
19099 int i = dowpn;
19100 FFCore.reset_script_engine_data(ScriptType::Item, i);
19101 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19102 did_scriptb=true;
19103 }
19104 }
19105
19106
6/12
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 418 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 418 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 418 times.
418 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
19107 {
19108 return false;
19109 }
19110
1/2
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
418 if(!no_jinx)
19111 did_scriptb = false;
19112 418 }
19113 else
19114 {
19115 390618 did_scriptb=false;
19116 }
19117
19118
5/6
✓ Branch 0 taken 364616 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 362030 times.
✓ Branch 3 taken 2586 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 362030 times.
398976 if(attackclk || action==attacking || action==sideswimattacking)
19119 {
19120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36946 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36946 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
19121
4/8
✓ Branch 0 taken 2586 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 2586 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2586 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36946 else if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19122 {
19123 if((xoff==0)||diagonalMovement)
19124 {
19125 if(DrunkUp()) dir=up;
19126 if(DrunkDown()) dir=down;
19127 }
19128
19129 if((yoff==0)||diagonalMovement)
19130 {
19131 if(DrunkLeft()) dir=left;
19132 if(DrunkRight()) dir=right;
19133 }
19134 }
19135
19136 36946 bool attacked = doattack();
19137
19138 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
19139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36946 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36946 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
19140
8/12
✓ Branch 0 taken 36946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26704 times.
✓ Branch 3 taken 10242 times.
✓ Branch 4 taken 4923 times.
✓ Branch 5 taken 21781 times.
✓ Branch 6 taken 4923 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4923 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4923 times.
36946 else if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
19141 {
19142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4923 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4923 if((xoff==0)||diagonalMovement)
19143 {
19144
2/2
✓ Branch 0 taken 4676 times.
✓ Branch 1 taken 247 times.
4923 if(DrunkUp()) dir=up;
19145
19146
2/2
✓ Branch 0 taken 4411 times.
✓ Branch 1 taken 512 times.
4923 if(DrunkDown()) dir=down;
19147 4923 }
19148
19149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4923 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4923 if((yoff==0)||diagonalMovement)
19150 {
19151
2/2
✓ Branch 0 taken 4428 times.
✓ Branch 1 taken 495 times.
4923 if(DrunkLeft()) dir=left;
19152
19153
2/2
✓ Branch 0 taken 4372 times.
✓ Branch 1 taken 551 times.
4923 if(DrunkRight()) dir=right;
19154 4923 }
19155 4923 }
19156
19157
6/10
✓ Branch 0 taken 34461 times.
✓ Branch 1 taken 2485 times.
✓ Branch 2 taken 34461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34461 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34461 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 34461 times.
36946 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
19158 {
19159 34461 return false;
19160 }
19161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
2485 else if(!attacked)
19162 {
19163 // Spin attack - change direction
19164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2485 if(spins>1 && attack != wHammer)
19165 {
19166 spins--;
19167
19168 if(spins%5==0)
19169 {
19170 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
19171 sfx(itemsbuf[id].usesound,pan(x.getInt()));
19172 }
19173 attackclk=1;
19174
19175 switch(dir)
19176 {
19177 case up:
19178 dir=left;
19179 break;
19180
19181 case right:
19182 dir=up;
19183 break;
19184
19185 case down:
19186 dir=right;
19187 break;
19188
19189 case left:
19190 dir=down;
19191 break;
19192 }
19193
19194 return false;
19195 }
19196 else
19197 {
19198 2485 spins=0;
19199 }
19200
19201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
2485 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
19202 2485 else {action=none; FFCore.setHeroAction(none);}
19203 2485 attackclk=0;
19204 2485 charging=0;
19205 2485 }
19206 2485 }
19207 364515 return true;
19208 402696 }
19209 458852 void HeroClass::movehero()
19210 {
19211 458852 bool earlyret = false;
19212
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 458852 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
458852 bool nohorz = (isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam);
19213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 458852 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
458852 bool novert = (isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam);
19214 458852 zfix dx, dy;
19215 458852 auto push=pushing;
19216 458852 pushing=0;
19217
19218
2/2
✓ Branch 0 taken 94337 times.
✓ Branch 1 taken 364515 times.
458852 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
19219 {
19220
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 364451 times.
364515 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
19221 64 return;
19222
19223
2/2
✓ Branch 0 taken 118078 times.
✓ Branch 1 taken 246373 times.
364451 if(action==walking) //still walking
19224 {
19225
9/10
✓ Branch 0 taken 180908 times.
✓ Branch 1 taken 65465 times.
✓ Branch 2 taken 114158 times.
✓ Branch 3 taken 66750 times.
✓ Branch 4 taken 60217 times.
✓ Branch 5 taken 53941 times.
✓ Branch 6 taken 3143 times.
✓ Branch 7 taken 57074 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3143 times.
246373 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
19226 {
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3143 times.
3143 if(attackclk>0) SetAttack();
19228 3143 else {action = none; FFCore.setHeroAction(none);}
19229 3143 hero_count=-1;
19230 3143 earlyret = true;
19231 3143 goto newmove_slide;
19232 }
19233
19234 243230 autostep=false;
19235 243230 } // endif (action==walking)
19236
19237
14/24
✓ Branch 0 taken 354646 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 354646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 354646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 354646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 354646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 354646 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 354646 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 354646 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 354646 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 354646 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2598 times.
✓ Branch 23 taken 352048 times.
361308 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
19238 {
19239 352048 action=none; FFCore.setHeroAction(none);
19240 352048 }
19241 361308 }
19242
19243
2/2
✓ Branch 0 taken 94337 times.
✓ Branch 1 taken 361308 times.
1005786 if(is_conveyor_stunned)
19244 {
19245 94337 dx = convey_forcex;
19246 94337 dy = convey_forcey;
19247 94337 convey_forcex = 0;
19248 94337 convey_forcey = 0;
19249
2/2
✓ Branch 0 taken 94336 times.
✓ Branch 1 taken 1 times.
94337 if(action != walking)
19250 {
19251 1 action = walking; FFCore.setHeroAction(walking);
19252 1 }
19253 94337 }
19254
1/2
✓ Branch 0 taken 361308 times.
✗ Branch 1 not taken.
361308 else if(diagonalMovement)
19255 {
19256
5/5
✓ Branch 0 taken 104102 times.
✓ Branch 1 taken 49207 times.
✓ Branch 2 taken 53209 times.
✓ Branch 3 taken 74097 times.
✓ Branch 4 taken 80693 times.
361308 switch(holddir)
19257 {
19258 case up:
19259
2/2
✓ Branch 0 taken 47248 times.
✓ Branch 1 taken 1959 times.
49207 if(!Up())
19260 {
19261 1959 holddir=-1;
19262 1959 }
19263
19264 49207 break;
19265
19266 case down:
19267
2/2
✓ Branch 0 taken 51211 times.
✓ Branch 1 taken 1998 times.
53209 if(!Down())
19268 {
19269 1998 holddir=-1;
19270 1998 }
19271
19272 53209 break;
19273
19274 case left:
19275
2/2
✓ Branch 0 taken 71726 times.
✓ Branch 1 taken 2371 times.
74097 if(!Left())
19276 {
19277 2371 holddir=-1;
19278 2371 }
19279
19280 74097 break;
19281
19282 case right:
19283
2/2
✓ Branch 0 taken 78282 times.
✓ Branch 1 taken 2411 times.
80693 if(!Right())
19284 {
19285 2411 holddir=-1;
19286 2411 }
19287
19288 80693 break;
19289
19290 default:
19291 104102 break;
19292 } //end switch
19293
19294
6/6
✓ Branch 0 taken 69011 times.
✓ Branch 1 taken 292297 times.
✓ Branch 2 taken 67047 times.
✓ Branch 3 taken 1964 times.
✓ Branch 4 taken 47248 times.
✓ Branch 5 taken 49212 times.
361308 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
19295 {
19296
4/10
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49212 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 49212 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
49212 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19297 {
19298 49212 dir=up;
19299 49212 }
19300 49212 holddir=up;
19301
19302
5/6
✓ Branch 0 taken 8041 times.
✓ Branch 1 taken 41171 times.
✓ Branch 2 taken 8033 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8033 times.
49212 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19303 {
19304 8033 shiftdir=right;
19305
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8033 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19306
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8033 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19307 8033 }
19308
5/6
✓ Branch 0 taken 6156 times.
✓ Branch 1 taken 35023 times.
✓ Branch 2 taken 6149 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6149 times.
41179 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19309 {
19310 6149 shiftdir=left;
19311
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6149 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19312
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6149 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19313 6149 }
19314 else
19315 {
19316 35030 shiftdir=-1;
19317 }
19318 49212 }
19319
6/6
✓ Branch 0 taken 70275 times.
✓ Branch 1 taken 336317 times.
✓ Branch 2 taken 68273 times.
✓ Branch 3 taken 2002 times.
✓ Branch 4 taken 17062 times.
✓ Branch 5 taken 53213 times.
406592 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
19320 {
19321
4/10
✓ Branch 0 taken 53213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53213 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 53213 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
53213 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19322 {
19323 53213 dir=down;
19324 53213 }
19325 53213 holddir=down;
19326
19327
5/6
✓ Branch 0 taken 6794 times.
✓ Branch 1 taken 46419 times.
✓ Branch 2 taken 6779 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6779 times.
53213 if(DrunkRight()&&shiftdir!=left&&!nohorz)
19328 {
19329 6779 shiftdir=right;
19330
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6779 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19331
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6779 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19332 6779 }
19333
5/6
✓ Branch 0 taken 8568 times.
✓ Branch 1 taken 37866 times.
✓ Branch 2 taken 8557 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8557 times.
46434 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
19334 {
19335 8557 shiftdir=left;
19336
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8557 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19337
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8557 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19338 8557 }
19339 else
19340 {
19341 37877 shiftdir=-1;
19342 }
19343 53213 }
19344
6/6
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 279139 times.
✓ Branch 2 taken 71866 times.
✓ Branch 3 taken 2374 times.
✓ Branch 4 taken 140 times.
✓ Branch 5 taken 74100 times.
353379 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
19345 {
19346
3/6
✓ Branch 0 taken 74100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74100 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 74100 times.
74100 if(charging==0 && spins==0 && action != sideswimattacking)
19347 {
19348 74100 dir=left;
19349 74100 }
19350 74100 sideswimdir = left;
19351 74100 holddir=left;
19352
19353
4/6
✓ Branch 0 taken 8531 times.
✓ Branch 1 taken 65569 times.
✓ Branch 2 taken 8531 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8531 times.
74100 if(DrunkUp()&&shiftdir!=down&&!novert)
19354 {
19355 8531 shiftdir=up;
19356 8531 }
19357
5/6
✓ Branch 0 taken 8153 times.
✓ Branch 1 taken 57416 times.
✓ Branch 2 taken 8152 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8152 times.
65569 else if(DrunkDown()&&shiftdir!=up&&!novert)
19358 {
19359 8152 shiftdir=down;
19360 8152 }
19361 else
19362 {
19363 57417 shiftdir=-1;
19364 }
19365 74100 }
19366
5/6
✓ Branch 0 taken 80693 times.
✓ Branch 1 taken 198586 times.
✓ Branch 2 taken 78282 times.
✓ Branch 3 taken 2411 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80693 times.
279279 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
19367 {
19368
3/6
✓ Branch 0 taken 80693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80693 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 80693 times.
80693 if(charging==0 && spins==0 && action != sideswimattacking)
19369 {
19370 80693 dir=right;
19371 80693 }
19372 80693 sideswimdir = right;
19373 80693 holddir=right;
19374
19375
4/6
✓ Branch 0 taken 11268 times.
✓ Branch 1 taken 69425 times.
✓ Branch 2 taken 11268 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11268 times.
80693 if(DrunkUp()&&shiftdir!=down&&!novert)
19376 {
19377 11268 shiftdir=up;
19378 11268 }
19379
5/6
✓ Branch 0 taken 8907 times.
✓ Branch 1 taken 60518 times.
✓ Branch 2 taken 8905 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8905 times.
69425 else if(DrunkDown()&&shiftdir!=up&&!novert)
19380 {
19381 8905 shiftdir=down;
19382 8905 }
19383 else
19384 {
19385 60520 shiftdir=-1;
19386 }
19387 80693 }
19388 else
19389 {
19390 198586 int32_t wtry = iswaterex_z3(MAPCOMBO(x,y+15), -1, x,y+15, true, false);
19391 198586 int32_t wtry8 = iswaterex_z3(MAPCOMBO(x+15,y+15), -1, x+15,y+15, true, false);
19392 198586 int32_t wtrx = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)), -1, x,y+(bigHitbox?0:8), true, false);
19393 198586 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)), -1, x+15,y+(bigHitbox?0:8), true, false);
19394 198586 int32_t wtrc = iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?8:12)), -1, x+8,y+(bigHitbox?8:12), true, false);
19395
19396
9/12
✓ Branch 0 taken 28585 times.
✓ Branch 1 taken 170001 times.
✓ Branch 2 taken 28528 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 185 times.
✓ Branch 5 taken 28343 times.
✓ Branch 6 taken 28528 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28528 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28528 times.
✗ Branch 11 not taken.
198586 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
19397 {
19398
8/12
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 27949 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28528 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
19399 {
19400 //action=swimming;
19401
2/12
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
294 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
19402 {
19403 hopclk = 0xFF;
19404 }
19405 294 }
19406 28528 }
19407 198586 earlyret = true;
19408 }
19409
2/2
✓ Branch 0 taken 198586 times.
✓ Branch 1 taken 257218 times.
455804 if(earlyret)
19410 198586 dx = dy = 0;
19411 257218 else get_move(holddir,dx,dy,dir);
19412 455804 }
19413 else //4-way
19414 {
19415 shiftdir = -1;
19416 holddir = -1;
19417 if(!novert && DrunkUp())
19418 {
19419 holddir = dir = up;
19420 }
19421 else if(!novert && DrunkDown())
19422 {
19423 holddir = dir = down;
19424 }
19425 else if(!nohorz && DrunkLeft())
19426 {
19427 holddir = dir = left;
19428 }
19429 else if(!nohorz && DrunkRight())
19430 {
19431 holddir = dir = right;
19432 }
19433 get_move(holddir,dx,dy,dir);
19434 }
19435
19436 newmove_slide:
19437
3/4
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 364451 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159 times.
364610 if(conv_forcedir > -1 && !spins)
19438 159 dir = conv_forcedir;
19439
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 364451 times.
364610 if(!is_conveyor_stunned)
19440 {
19441
6/8
✓ Branch 0 taken 363363 times.
✓ Branch 1 taken 1088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 363363 times.
✓ Branch 4 taken 2204 times.
✓ Branch 5 taken 361159 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2204 times.
364451 bool is_inair = (z > 0 || fakez > 0) || (sideview_mode() && !get_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW) && !isStanding(true));
19442 364451 auto ic = ice_combo;
19443
2/2
✓ Branch 0 taken 2706 times.
✓ Branch 1 taken 361745 times.
364451 if(!is_inair) //maintain momentum when jumping
19444 {
19445 361745 const int sens = 2;
19446
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 361159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
361745 if(sideview_mode() && !get_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW)) // check *below you* in sideview
19447 {
19448 586 int xs[] = {x+sens, x+15-sens};
19449 586 bool found = false;
19450
2/2
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1172 times.
1758 for(int q = 0; q < 2; ++q)
19451 {
19452 1172 auto ice = get_icy(xs[q], y+16, ICY_PLAYER);
19453
1/2
✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
1172 if(ice)
19454 {
19455 ic = ice_combo = ice;
19456 found = true;
19457 break;
19458 }
19459 1172 }
19460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
586 if(!found)
19461 586 ic = ice_combo = 0;
19462 586 }
19463 else
19464 {
19465 361159 auto ty = y+(bigHitbox?0:8);
19466 361159 int xs[] = {x+7, x+sens, x+sens, x+15-sens, x+15-sens};
19467 361159 int ys[] = {y+(bigHitbox?8:12), ty+sens, y+15-sens, ty+sens, y+15-sens};
19468 361159 bool found = false;
19469
2/2
✓ Branch 0 taken 361159 times.
✓ Branch 1 taken 1805795 times.
2166954 for(int q = 0; q < 5; ++q)
19470 {
19471 1805795 auto ice = get_icy(xs[q], ys[q], ICY_PLAYER);
19472
1/2
✓ Branch 0 taken 1805795 times.
✗ Branch 1 not taken.
1805795 if(ice)
19473 {
19474 ic = ice_combo = ice;
19475 found = true;
19476 break;
19477 }
19478 1805795 }
19479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361159 times.
361159 if(!found)
19480 361159 ic = ice_combo = 0;
19481 }
19482 361745 }
19483
2/2
✓ Branch 0 taken 364291 times.
✓ Branch 1 taken 160 times.
364451 if(script_ice_combo)
19484 {
19485
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
19486 160 ic = script_ice_combo;
19487 else ic = 0;
19488 160 }
19489
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 364291 times.
364451 if(ic)
19490 {
19491 160 handle_slide(combobuf[ic], dx, dy);
19492 160 earlyret = false;
19493 160 }
19494 364291 else clear_ice();
19495 364451 }
19496 159 else clear_ice();
19497
2/2
✓ Branch 0 taken 257537 times.
✓ Branch 1 taken 107073 times.
364610 if(earlyret)
19498 107073 return;
19499
19500
2/2
✓ Branch 0 taken 219278 times.
✓ Branch 1 taken 38259 times.
257537 if(!new_engine_move(dx,dy))
19501 38259 pushing = push+1;
19502 364674 }
19503
19504 418394 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
19505 {
19506 418394 dx = 0; dy = 0;
19507
6/8
✓ Branch 0 taken 257218 times.
✓ Branch 1 taken 161176 times.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257218 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 161176 times.
✓ Branch 7 taken 418394 times.
418394 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
19508 322352 return;
19509
19510 418394 zfix base_movepix(zfix(steprate) / 100);
19511 418394 zfix movepix(base_movepix);
19512 418394 zfix up_step(zfix(game->get_sideswim_up()) / 100);
19513 418394 zfix left_step(zfix(game->get_sideswim_side()) / 100);
19514 418394 zfix right_step(zfix(game->get_sideswim_side()) / 100);
19515 418394 zfix down_step(zfix(game->get_sideswim_down()) / 100);
19516 418394 std::vector<zfix*> steps;
19517
2/2
✓ Branch 0 taken 257218 times.
✓ Branch 1 taken 161176 times.
418394 steps.push_back(&movepix);
19518
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&up_step);
19519
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&left_step);
19520
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&right_step);
19521
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&down_step);
19522
19523
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 mod_steps(steps);
19524
19525
2/4
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
257218 up_step = -up_step;
19526
2/4
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
257218 left_step = -left_step;
19527
19528
19529
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 zfix step(movepix);
19530
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 zfix step_diag(movepix);
19531
19532
19533
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 if (diagonalMovement)
19534 {
19535
6/6
✓ Branch 0 taken 208006 times.
✓ Branch 1 taken 49212 times.
✓ Branch 2 taken 43344 times.
✓ Branch 3 taken 251350 times.
✓ Branch 4 taken 87719 times.
✓ Branch 5 taken 4837 times.
392212 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
19536
4/4
✓ Branch 0 taken 153600 times.
✓ Branch 1 taken 97750 times.
✓ Branch 2 taken 37244 times.
✓ Branch 3 taken 190844 times.
251350 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
19537 {
19538
4/6
✓ Branch 0 taken 66374 times.
✓ Branch 1 taken 161176 times.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
227550 step = STEP_DIAGONAL(step);
19539
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 up_step = STEP_DIAGONAL(up_step);
19540
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 left_step = STEP_DIAGONAL(left_step);
19541
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 right_step = STEP_DIAGONAL(right_step);
19542
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 down_step = STEP_DIAGONAL(down_step);
19543 66374 }
19544
4/5
✓ Branch 0 taken 49212 times.
✓ Branch 1 taken 53213 times.
✓ Branch 2 taken 74100 times.
✓ Branch 3 taken 80693 times.
✗ Branch 4 not taken.
257218 switch (movedir)
19545 {
19546 case up:
19547
3/3
✓ Branch 0 taken 6149 times.
✓ Branch 1 taken 8033 times.
✓ Branch 2 taken 35030 times.
49212 switch (shiftdir)
19548 {
19549 case left:
19550
4/10
✓ Branch 0 taken 6149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6149 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6149 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6149 times.
✗ Branch 9 not taken.
6149 dx = IsSideSwim() ? left_step : -step;
19551 6149 break;
19552 case right:
19553
3/6
✓ Branch 0 taken 8033 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8033 times.
✓ Branch 4 taken 8033 times.
✗ Branch 5 not taken.
8033 dx = IsSideSwim() ? right_step : step;
19554 8033 break;
19555 }
19556
2/4
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49212 times.
49212 if (IsSideSwim())
19557 {
19558 dy = up_step;
19559 }
19560
2/4
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49212 times.
✗ Branch 3 not taken.
49212 else dy = -step;
19561 49212 break;
19562 case down:
19563
3/3
✓ Branch 0 taken 8557 times.
✓ Branch 1 taken 6779 times.
✓ Branch 2 taken 37877 times.
53213 switch (shiftdir)
19564 {
19565 case left:
19566
2/4
✓ Branch 0 taken 8557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8557 times.
✗ Branch 3 not taken.
8557 dx = -step;
19567
2/6
✓ Branch 0 taken 8557 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8557 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8557 if (IsSideSwim()) dx = left_step;
19568 8557 break;
19569 case right:
19570
1/2
✓ Branch 0 taken 6779 times.
✗ Branch 1 not taken.
6779 dx = step;
19571
2/6
✓ Branch 0 taken 6779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6779 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6779 if (IsSideSwim()) dx = right_step;
19572 6779 break;
19573 }
19574
3/6
✓ Branch 0 taken 53213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 53213 times.
✓ Branch 4 taken 53213 times.
✗ Branch 5 not taken.
53213 dy = IsSideSwim() ? down_step : step;
19575 53213 break;
19576 case left:
19577
3/3
✓ Branch 0 taken 8531 times.
✓ Branch 1 taken 8152 times.
✓ Branch 2 taken 57417 times.
74100 switch (shiftdir)
19578 {
19579 case up:
19580
2/4
✓ Branch 0 taken 8531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8531 times.
8531 if (IsSideSwim())
19581 {
19582 dy = up_step;
19583 }
19584
2/4
✓ Branch 0 taken 8531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8531 times.
✗ Branch 3 not taken.
8531 else dy = -step;
19585 8531 break;
19586 case down:
19587
1/2
✓ Branch 0 taken 8152 times.
✗ Branch 1 not taken.
8152 dy = step;
19588
2/6
✓ Branch 0 taken 8152 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8152 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8152 if (IsSideSwim()) dy = down_step;
19589 8152 break;
19590 }
19591
4/10
✓ Branch 0 taken 74100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 74100 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 74100 times.
✗ Branch 9 not taken.
74100 dx = IsSideSwim() ? left_step : -step;
19592 74100 break;
19593 case right:
19594
3/3
✓ Branch 0 taken 11268 times.
✓ Branch 1 taken 8905 times.
✓ Branch 2 taken 60520 times.
80693 switch (shiftdir)
19595 {
19596 case up:
19597
4/8
✓ Branch 0 taken 11268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11268 times.
✗ Branch 7 not taken.
11268 if (!IsSideSwim()) dy = -step;
19598
2/4
✓ Branch 0 taken 11268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11268 times.
11268 if (IsSideSwim())
19599 {
19600 dy = up_step;
19601 }
19602 11268 break;
19603 case down:
19604
1/2
✓ Branch 0 taken 8905 times.
✗ Branch 1 not taken.
8905 dy = step;
19605
2/6
✓ Branch 0 taken 8905 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8905 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8905 if (IsSideSwim()) dy = down_step;
19606 8905 break;
19607 }
19608
3/6
✓ Branch 0 taken 80693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 80693 times.
✓ Branch 4 taken 80693 times.
✗ Branch 5 not taken.
80693 dx = IsSideSwim() ? right_step : step;
19609 80693 break;
19610 };
19611 257218 }
19612 else
19613 {
19614 switch (movedir)
19615 {
19616 case up:
19617 dy = IsSideSwim() ? up_step : -step;
19618 break;
19619 case down:
19620 dy = IsSideSwim() ? down_step : step;
19621 break;
19622 case left:
19623 dx = IsSideSwim() ? left_step : -step;
19624 break;
19625 case right:
19626 dx = IsSideSwim() ? right_step : step;
19627 break;
19628 };
19629 }
19630
19631
5/8
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 256457 times.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 761 times.
257218 if (isSideViewHero() && slopeid)
19632 {
19633 dy += (dx*slopeid);
19634 }
19635
19636
6/18
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257218 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257218 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 257218 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 257218 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
257218 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
19637 {
19638 257218 facedir = movedir;
19639 257218 }
19640 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19641 {
19642 facedir = shiftdir;
19643 }
19644 579570 }
19645
19646 257537 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
19647 {
19648
3/4
✓ Branch 0 taken 72957 times.
✓ Branch 1 taken 184580 times.
✓ Branch 2 taken 72957 times.
✗ Branch 3 not taken.
257537 if(!dx && !dy) return true;
19649
5/8
✓ Branch 0 taken 251247 times.
✓ Branch 1 taken 6290 times.
✓ Branch 2 taken 251247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 251247 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 251247 times.
257537 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19650 {
19651 251247 herostep();
19652
19653 //ack... don't walk if in midair! -DD
19654
11/14
✓ Branch 0 taken 251247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 251247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250270 times.
✓ Branch 5 taken 977 times.
✓ Branch 6 taken 250270 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 761 times.
✓ Branch 9 taken 249509 times.
✓ Branch 10 taken 652 times.
✓ Branch 11 taken 109 times.
✓ Branch 12 taken 200 times.
✓ Branch 13 taken 452 times.
251247 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
19655 {
19656 249818 action=walking; FFCore.setHeroAction(walking);
19657 249818 }
19658
19659
2/2
✓ Branch 0 taken 238059 times.
✓ Branch 1 taken 13188 times.
251247 if(++hero_count > (16*hero_animation_speed))
19660 13188 hero_count=0;
19661 251247 }
19662
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 3142 times.
6290 else if(!(frame & 1))
19663 {
19664 3142 herostep();
19665 3142 }
19666
19667 257537 bool ret = true;
19668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 257537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
257537 if(charging==0 || attack!=wHammer)
19669 {
19670 257537 ret = movexy(dx,dy,false,false,true);
19671 257537 }
19672 257537 return ret;
19673 257537 }
19674
19675 7461833 void HeroClass::moveOld(int32_t d2)
19676 {
19677 static bool totalskip = false;
19678
19679
3/6
✓ Branch 0 taken 7461833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7461833 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7461833 times.
7461833 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
19680 return;
19681
19682 7461833 int32_t dx=0,dy=0;
19683 7461833 int32_t xstep=lsteps[x.getInt()&7];
19684 7461833 int32_t ystep=lsteps[y.getInt()&7];
19685 7461833 int32_t z3skip=0;
19686 7461833 int32_t z3diagskip=0;
19687
5/6
✓ Branch 0 taken 200742 times.
✓ Branch 1 taken 7261091 times.
✓ Branch 2 taken 200680 times.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
14722986 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || hero_scr->flags2&fAIRCOMBOS)) ||
19688
5/6
✓ Branch 0 taken 190641 times.
✓ Branch 1 taken 7070512 times.
✓ Branch 2 taken 104043 times.
✓ Branch 3 taken 86598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 104043 times.
7261153 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
19689
2/2
✓ Branch 0 taken 7436018 times.
✓ Branch 1 taken 25815 times.
7461833 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
19690 7461833 bool is_swimming = (action == swimming);
19691
19692 //slow walk combo, or charging, moves at 2/3 speed
19693 if(
19694
4/4
✓ Branch 0 taken 7360999 times.
✓ Branch 1 taken 100834 times.
✓ Branch 2 taken 201043 times.
✓ Branch 3 taken 7159956 times.
7562667 (!is_swimming && (slowcharging ^ slowcombo))||
19695
2/2
✓ Branch 0 taken 100834 times.
✓ Branch 1 taken 7159956 times.
7260790 (is_swimming && (zinit.hero_swim_speed>60))
19696 )
19697 {
19698 301877 totalskip = false;
19699
19700
2/2
✓ Branch 0 taken 49244 times.
✓ Branch 1 taken 252633 times.
301877 if(diagonalMovement)
19701 {
19702 49244 skipstep=(skipstep+1)%6;
19703
19704
2/2
✓ Branch 0 taken 25024 times.
✓ Branch 1 taken 24220 times.
49244 if(skipstep%2==0) z3skip=1;
19705 25024 else z3skip=0;
19706
19707
2/2
✓ Branch 0 taken 33205 times.
✓ Branch 1 taken 16039 times.
49244 if(skipstep%3==0) z3diagskip=1;
19708 33205 else z3diagskip=0;
19709 49244 }
19710 else
19711 {
19712
2/2
✓ Branch 0 taken 165339 times.
✓ Branch 1 taken 87294 times.
252633 if(d2<left)
19713 {
19714
2/2
✓ Branch 0 taken 99954 times.
✓ Branch 1 taken 65385 times.
165339 if(ystep>1)
19715 {
19716 65385 skipstep^=1;
19717 65385 ystep=skipstep;
19718 65385 }
19719 165339 }
19720 else
19721 {
19722
2/2
✓ Branch 0 taken 53050 times.
✓ Branch 1 taken 34244 times.
87294 if(xstep>1)
19723 {
19724 34244 skipstep^=1;
19725 34244 xstep=skipstep;
19726 34244 }
19727 }
19728 }
19729 301877 }
19730 // else if(is_swimming || (slowcharging && slowcombo))
19731 else if(
19732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7159956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7160067 (is_swimming && (zinit.hero_swim_speed<60))||
19733
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7159845 times.
7159956 (slowcharging && slowcombo)
19734 )
19735 {
19736 //swimming, or charging on a slow combo, moves at 1/2 speed
19737 111 totalskip = !totalskip;
19738
19739
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
19740 {
19741 skipstep=0;
19742 }
19743 111 }
19744 else
19745 {
19746 7159845 totalskip = false;
19747
19748
2/2
✓ Branch 0 taken 5124956 times.
✓ Branch 1 taken 2034889 times.
7159845 if(diagonalMovement)
19749 {
19750 2034889 skipstep=0;
19751 2034889 }
19752 }
19753
19754
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 7461777 times.
7461833 if(!totalskip)
19755 {
19756
2/2
✓ Branch 0 taken 2084133 times.
✓ Branch 1 taken 5377644 times.
7461777 if(diagonalMovement)
19757 {
19758
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 446218 times.
✓ Branch 2 taken 376935 times.
✓ Branch 3 taken 662678 times.
✓ Branch 4 taken 598302 times.
2084133 switch(d2)
19759 {
19760 case up:
19761
2/2
✓ Branch 0 taken 45459 times.
✓ Branch 1 taken 400759 times.
446218 if(shiftdir==left)
19762 {
19763
2/2
✓ Branch 0 taken 35961 times.
✓ Branch 1 taken 9498 times.
45459 if(walkable)
19764 {
19765 35961 dy-=1-z3diagskip;
19766 35961 dx-=1-z3diagskip;
19767 35961 z3step=2;
19768 35961 }
19769 else
19770 {
19771 9498 dx-=1-z3diagskip;
19772 9498 z3step=2;
19773 }
19774 45459 }
19775
2/2
✓ Branch 0 taken 54669 times.
✓ Branch 1 taken 346090 times.
400759 else if(shiftdir==right)
19776 {
19777
2/2
✓ Branch 0 taken 43543 times.
✓ Branch 1 taken 11126 times.
54669 if(walkable)
19778 {
19779 43543 dy-=1-z3diagskip;
19780 43543 dx+=1-z3diagskip;
19781 43543 z3step=2;
19782 43543 }
19783 else
19784 {
19785 11126 dx+=1-z3diagskip;
19786 11126 z3step=2;
19787 }
19788 54669 }
19789 else
19790 {
19791
2/2
✓ Branch 0 taken 62104 times.
✓ Branch 1 taken 283986 times.
346090 if(walkable)
19792 {
19793 283986 dy-=z3step-z3skip;
19794 283986 z3step=(z3step%2)+1;
19795 283986 }
19796 }
19797
19798 446218 break;
19799
19800 case down:
19801
2/2
✓ Branch 0 taken 50975 times.
✓ Branch 1 taken 325960 times.
376935 if(shiftdir==left)
19802 {
19803
2/2
✓ Branch 0 taken 38415 times.
✓ Branch 1 taken 12560 times.
50975 if(walkable)
19804 {
19805 38415 dy+=1-z3diagskip;
19806 38415 dx-=1-z3diagskip;
19807 38415 z3step=2;
19808 38415 }
19809 else
19810 {
19811 12560 dx-=1-z3diagskip;
19812 12560 z3step=2;
19813 }
19814 50975 }
19815
2/2
✓ Branch 0 taken 52314 times.
✓ Branch 1 taken 273646 times.
325960 else if(shiftdir==right)
19816 {
19817
2/2
✓ Branch 0 taken 39775 times.
✓ Branch 1 taken 12539 times.
52314 if(walkable)
19818 {
19819 39775 dy+=1-z3diagskip;
19820 39775 dx+=1-z3diagskip;
19821 39775 z3step=2;
19822 39775 }
19823 else
19824 {
19825 12539 dx+=1-z3diagskip;
19826 12539 z3step=2;
19827 }
19828 52314 }
19829 else
19830 {
19831
2/2
✓ Branch 0 taken 47541 times.
✓ Branch 1 taken 226105 times.
273646 if(walkable)
19832 {
19833 226105 dy+=z3step-z3skip;
19834 226105 z3step=(z3step%2)+1;
19835 226105 }
19836 }
19837
19838 376935 break;
19839
19840 case right:
19841
2/2
✓ Branch 0 taken 592932 times.
✓ Branch 1 taken 69746 times.
662678 if(shiftdir==up)
19842 {
19843
2/2
✓ Branch 0 taken 58004 times.
✓ Branch 1 taken 11742 times.
69746 if(walkable)
19844 {
19845 58004 dy-=1-z3diagskip;
19846 58004 dx+=1-z3diagskip;
19847 58004 z3step=2;
19848 58004 }
19849 else
19850 {
19851 11742 dy-=1-z3diagskip;
19852 11742 z3step=2;
19853 }
19854 69746 }
19855
2/2
✓ Branch 0 taken 54368 times.
✓ Branch 1 taken 538564 times.
592932 else if(shiftdir==down)
19856 {
19857
2/2
✓ Branch 0 taken 45042 times.
✓ Branch 1 taken 9326 times.
54368 if(walkable)
19858 {
19859 45042 dy+=1-z3diagskip;
19860 45042 dx+=1-z3diagskip;
19861 45042 z3step=2;
19862 45042 }
19863 else
19864 {
19865 9326 dy+=1-z3diagskip;
19866 9326 z3step=2;
19867 }
19868 54368 }
19869 else
19870 {
19871
2/2
✓ Branch 0 taken 61923 times.
✓ Branch 1 taken 476641 times.
538564 if(walkable)
19872 {
19873 476641 dx+=z3step-z3skip;
19874 476641 z3step=(z3step%2)+1;
19875 476641 }
19876 }
19877
19878 662678 break;
19879
19880 case left:
19881
2/2
✓ Branch 0 taken 532641 times.
✓ Branch 1 taken 65661 times.
598302 if(shiftdir==up)
19882 {
19883
2/2
✓ Branch 0 taken 55678 times.
✓ Branch 1 taken 9983 times.
65661 if(walkable)
19884 {
19885 55678 dy-=1-z3diagskip;
19886 55678 dx-=1-z3diagskip;
19887 55678 z3step=2;
19888 55678 }
19889 else
19890 {
19891 9983 dy-=1-z3diagskip;
19892 9983 z3step=2;
19893 }
19894 65661 }
19895
2/2
✓ Branch 0 taken 50757 times.
✓ Branch 1 taken 481884 times.
532641 else if(shiftdir==down)
19896 {
19897
2/2
✓ Branch 0 taken 42812 times.
✓ Branch 1 taken 7945 times.
50757 if(walkable)
19898 {
19899 42812 dy+=1-z3diagskip;
19900 42812 dx-=1-z3diagskip;
19901 42812 z3step=2;
19902 42812 }
19903 else
19904 {
19905 7945 dy+=1-z3diagskip;
19906 7945 z3step=2;
19907 }
19908 50757 }
19909 else
19910 {
19911
2/2
✓ Branch 0 taken 50775 times.
✓ Branch 1 taken 431109 times.
481884 if(walkable)
19912 {
19913 431109 dx-=z3step-z3skip;
19914 431109 z3step=(z3step%2)+1;
19915 431109 }
19916 }
19917
19918 598302 break;
19919 }
19920 2084133 }
19921 else
19922 {
19923
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1268161 times.
✓ Branch 2 taken 1035864 times.
✓ Branch 3 taken 1490695 times.
✓ Branch 4 taken 1582924 times.
5377644 switch(d2)
19924 {
19925 case up:
19926
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 1267853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
1268161 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
19927
19928 1268161 break;
19929
19930 case down:
19931
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1035810 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
1035864 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
19932
19933 1035864 break;
19934
19935 case left:
19936 1490695 dx-=xstep;
19937 1490695 break;
19938
19939 case right:
19940 1582924 dx+=xstep;
19941 1582924 break;
19942 }
19943 }
19944 7461777 }
19945
19946
8/16
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7436018 times.
✓ Branch 2 taken 7435739 times.
✓ Branch 3 taken 26094 times.
✓ Branch 4 taken 7435470 times.
✓ Branch 5 taken 269 times.
✓ Branch 6 taken 7435470 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7435470 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7461833 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
19947 {
19948 7435470 dir=d2;
19949 7435470 }
19950
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 26363 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
26363 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19951 {
19952 dir = shiftdir;
19953 }
19954
19955
3/4
✓ Branch 0 taken 7360999 times.
✓ Branch 1 taken 100834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7360999 times.
7461833 if(action != swimming && !IsSideSwim())
19956 {
19957 7360999 herostep();
19958
19959 //ack... don't walk if in midair! -DD
19960
12/14
✓ Branch 0 taken 7335184 times.
✓ Branch 1 taken 25815 times.
✓ Branch 2 taken 7334905 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 7325040 times.
✓ Branch 5 taken 9865 times.
✓ Branch 6 taken 7325040 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 190641 times.
✓ Branch 9 taken 7134399 times.
✓ Branch 10 taken 104043 times.
✓ Branch 11 taken 86598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 104043 times.
7360999 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
19961 {
19962 7220997 action=walking; FFCore.setHeroAction(walking);
19963 7220997 }
19964
19965
2/2
✓ Branch 0 taken 6967261 times.
✓ Branch 1 taken 393738 times.
7360999 if(++hero_count > (16*hero_animation_speed))
19966 393738 hero_count=0;
19967 7360999 }
19968
2/2
✓ Branch 0 taken 50397 times.
✓ Branch 1 taken 50437 times.
100834 else if(!(frame & 1))
19969 {
19970 50437 herostep();
19971 50437 }
19972
19973
3/4
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7436018 times.
✓ Branch 2 taken 25815 times.
✗ Branch 3 not taken.
7461833 if(charging==0 || attack!=wHammer)
19974 {
19975 7461833 sprite::move((zfix)dx,(zfix)dy);
19976 7461833 }
19977 7461833 }
19978 7832512 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
19979 {
19980
4/6
✓ Branch 0 taken 7829913 times.
✓ Branch 1 taken 2599 times.
✓ Branch 2 taken 7829913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7829913 times.
7832512 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
19981 2599 return;
19982
19983
3/4
✓ Branch 0 taken 7461833 times.
✓ Branch 1 taken 368080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7461833 times.
7829913 if(!get_qr(qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
19984 {
19985 7461833 moveOld(d2);
19986 7461833 return;
19987 }
19988
19989
4/8
✓ Branch 0 taken 9005 times.
✓ Branch 1 taken 359075 times.
✓ Branch 2 taken 9005 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9005 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
727155 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || hero_scr->flags2&fAIRCOMBOS)) ||
19990
5/6
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 356621 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 1404 times.
✓ Branch 4 taken 2454 times.
✗ Branch 5 not taken.
359075 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
19991 //!DIMITODO: add QR for slow combos under hero
19992
4/4
✓ Branch 0 taken 359075 times.
✓ Branch 1 taken 9005 times.
✓ Branch 2 taken 9005 times.
✓ Branch 3 taken 18010 times.
386090 if(slowcombo) for (int32_t i = 1; i <= 2; ++i)
19993 {
19994
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 17426 times.
18010 if (get_scr_layer_valid(hero_screen, i))
19995 {
19996
2/2
✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 5522 times.
17426 if (get_qr(qr_OLD_BRIDGE_COMBOS))
19997 {
19998
2/4
✓ Branch 0 taken 11904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11904 times.
✗ Branch 3 not taken.
11904 if (combobuf[MAPCOMBO2(i-1,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8))
19999 {
20000 slowcombo = false;
20001 break;
20002 }
20003 11904 }
20004 else
20005 {
20006
2/4
✓ Branch 0 taken 5522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5522 times.
✗ Branch 3 not taken.
5522 if (combobuf[MAPCOMBO2(i-1,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8))
20007 {
20008 slowcombo = false;
20009 break;
20010 }
20011 }
20012 17426 }
20013 27015 }
20014
2/2
✓ Branch 0 taken 365811 times.
✓ Branch 1 taken 2269 times.
368080 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
20015 368080 bool is_swimming = (action == swimming);
20016 368080 bool fastSwim = (zinit.hero_swim_speed>60);
20017 368080 zfix rate(steprate);
20018 368080 int32_t shieldid = getCurrentActiveShield();
20019
1/2
✓ Branch 0 taken 368080 times.
✗ Branch 1 not taken.
368080 if(shieldid > -1)
20020 {
20021 itemdata const& shield = itemsbuf[shieldid];
20022 if(shield.flags & item_flag10) //Change Speed flag
20023 {
20024 zfix perc = shield.misc7;
20025 perc /= 100;
20026 if(perc < 0)
20027 perc = (perc*-1)+1;
20028 rate = (rate * perc) + shield.misc8;
20029 }
20030 }
20031
20032 368080 zfix dx, dy;
20033 368080 zfix movepix(rate / 100);
20034 368080 zfix step(movepix);
20035 368080 zfix step_diag(movepix);
20036 368080 zfix up_step(game->get_sideswim_up() / -100.0);
20037 368080 zfix left_step(game->get_sideswim_side() / -100.0);
20038 368080 zfix right_step(game->get_sideswim_side() / 100.0);
20039 368080 zfix down_step(game->get_sideswim_down() / 100.0);
20040 368080 bool checkladder = false;
20041
20042
2/2
✓ Branch 0 taken 367877 times.
✓ Branch 1 taken 203 times.
368080 if(hero_newstep > movepix) hero_newstep = movepix;
20043
2/2
✓ Branch 0 taken 367877 times.
✓ Branch 1 taken 203 times.
368080 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
20044 //2/3 speed
20045
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 368080 times.
✓ Branch 2 taken 356888 times.
✓ Branch 3 taken 356888 times.
✓ Branch 4 taken 368080 times.
✓ Branch 5 taken 356888 times.
368080 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
20046 {
20047 724968 step = ((step / 3.0) * 2);
20048 724968 step_diag = ((step_diag / 3.0) * 2);
20049 724968 up_step = ((up_step / 3.0) * 2);
20050 724968 left_step = ((left_step / 3.0) * 2);
20051 724968 right_step = ((right_step / 3.0) * 2);
20052 724968 down_step = ((down_step / 3.0) * 2);
20053 724968 }
20054 //1/2 speed
20055
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 356857 times.
356888 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
20056 {
20057 31 step /= 2;
20058 31 step_diag /= 2;
20059 31 up_step /= 2;
20060 31 left_step /= 2;
20061 31 right_step /= 2;
20062 31 down_step /= 2;
20063 31 }
20064 //normal speed
20065 else
20066 {
20067 //no modification
20068 }
20069
20070
1/2
✓ Branch 0 taken 368080 times.
✗ Branch 1 not taken.
368080 if(diagonalMovement)
20071 {
20072
6/6
✓ Branch 0 taken 290293 times.
✓ Branch 1 taken 77787 times.
✓ Branch 2 taken 311341 times.
✓ Branch 3 taken 21048 times.
✓ Branch 4 taken 136480 times.
✓ Branch 5 taken 252648 times.
560267 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
20073
4/4
✓ Branch 0 taken 227037 times.
✓ Branch 1 taken 205989 times.
✓ Branch 2 taken 17618 times.
✓ Branch 3 taken 209419 times.
21048 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
20074 {
20075
3/4
✓ Branch 0 taken 75915 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75915 times.
581315 if(hero_newstep > 0 && hero_newstep_diag > 0)
20076 {
20077 75915 step = STEP_DIAGONAL(step);
20078 75915 step_diag = STEP_DIAGONAL(step_diag);
20079 75915 up_step = STEP_DIAGONAL(up_step);
20080 75915 left_step = STEP_DIAGONAL(left_step);
20081 75915 right_step = STEP_DIAGONAL(right_step);
20082 75915 down_step = STEP_DIAGONAL(down_step);
20083 75915 }
20084 76019 }
20085
2/2
✓ Branch 0 taken 250719 times.
✓ Branch 1 taken 34719 times.
285438 if(hero_newstep < step) step = hero_newstep; //handle collision
20086
2/2
✓ Branch 0 taken 273968 times.
✓ Branch 1 taken 11470 times.
285438 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
20087
5/5
✓ Branch 0 taken 82642 times.
✓ Branch 1 taken 77787 times.
✓ Branch 2 taken 76444 times.
✓ Branch 3 taken 105525 times.
✓ Branch 4 taken 108324 times.
285438 switch(d2)
20088 {
20089 case up:
20090
3/3
✓ Branch 0 taken 61709 times.
✓ Branch 1 taken 7704 times.
✓ Branch 2 taken 8374 times.
77787 switch(shiftdir)
20091 {
20092 case left:
20093 7704 dx = -step_diag;
20094
1/2
✓ Branch 0 taken 7704 times.
✗ Branch 1 not taken.
7704 if (IsSideSwim()) dx = left_step;
20095 7704 break;
20096 case right:
20097 8374 dx = step_diag;
20098
1/2
✓ Branch 0 taken 8374 times.
✗ Branch 1 not taken.
8374 if (IsSideSwim()) dx = right_step;
20099 8374 break;
20100 }
20101
2/2
✓ Branch 0 taken 11035 times.
✓ Branch 1 taken 66752 times.
77787 if(walkable)
20102 {
20103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66752 times.
66752 if (!IsSideSwim()) dy = -step;
20104
1/2
✓ Branch 0 taken 66752 times.
✗ Branch 1 not taken.
66752 if (IsSideSwim())
20105 {
20106 dy = up_step;
20107 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20108 }
20109 66752 }
20110 77787 break;
20111 case down:
20112
3/3
✓ Branch 0 taken 57004 times.
✓ Branch 1 taken 10047 times.
✓ Branch 2 taken 9393 times.
76444 switch(shiftdir)
20113 {
20114 case left:
20115 10047 dx = -step_diag;
20116
1/2
✓ Branch 0 taken 10047 times.
✗ Branch 1 not taken.
10047 if (IsSideSwim()) dx = left_step;
20117 10047 break;
20118 case right:
20119 9393 dx = step_diag;
20120
1/2
✓ Branch 0 taken 9393 times.
✗ Branch 1 not taken.
9393 if (IsSideSwim()) dx = right_step;
20121 9393 break;
20122 }
20123
2/2
✓ Branch 0 taken 8382 times.
✓ Branch 1 taken 68062 times.
76444 if(walkable)
20124 {
20125 68062 dy = step;
20126
1/2
✓ Branch 0 taken 68062 times.
✗ Branch 1 not taken.
68062 if (IsSideSwim()) dy = down_step;
20127 68062 }
20128 76444 break;
20129 case left:
20130
3/3
✓ Branch 0 taken 85010 times.
✓ Branch 1 taken 10934 times.
✓ Branch 2 taken 9581 times.
105525 switch(shiftdir)
20131 {
20132 case up:
20133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10934 times.
10934 if (!IsSideSwim()) dy = -step_diag;
20134
1/2
✓ Branch 0 taken 10934 times.
✗ Branch 1 not taken.
10934 if (IsSideSwim())
20135 {
20136 dy = up_step;
20137 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20138 }
20139 10934 break;
20140 case down:
20141 9581 dy = step_diag;
20142
1/2
✓ Branch 0 taken 9581 times.
✗ Branch 1 not taken.
9581 if (IsSideSwim()) dy = down_step;
20143 9581 break;
20144 }
20145
2/2
✓ Branch 0 taken 9965 times.
✓ Branch 1 taken 95560 times.
105525 if(walkable)
20146 {
20147 95560 dx = -step;
20148
1/2
✓ Branch 0 taken 95560 times.
✗ Branch 1 not taken.
95560 if (IsSideSwim()) dx = left_step;
20149 95560 }
20150 105525 break;
20151 case right:
20152
3/3
✓ Branch 0 taken 88338 times.
✓ Branch 1 taken 10728 times.
✓ Branch 2 taken 9258 times.
108324 switch(shiftdir)
20153 {
20154 case up:
20155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10728 times.
10728 if (!IsSideSwim()) dy = -step_diag;
20156
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if (IsSideSwim())
20157 {
20158 dy = up_step;
20159 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20160 }
20161 10728 break;
20162 case down:
20163 9258 dy = step_diag;
20164
1/2
✓ Branch 0 taken 9258 times.
✗ Branch 1 not taken.
9258 if (IsSideSwim()) dy = down_step;
20165 9258 break;
20166 }
20167
2/2
✓ Branch 0 taken 10374 times.
✓ Branch 1 taken 97950 times.
108324 if(walkable)
20168 {
20169 97950 dx = step;
20170
1/2
✓ Branch 0 taken 97950 times.
✗ Branch 1 not taken.
97950 if (IsSideSwim()) dx = right_step;
20171 97950 }
20172 108324 break;
20173 };
20174 450722 }
20175 else
20176 {
20177 if(hero_newstep < step) step = hero_newstep; //handle collision
20178 switch(d2)
20179 {
20180 case up:
20181 dy -= step;
20182 if (IsSideSwim()) dy = up_step;
20183 break;
20184 case down:
20185 dy += step;
20186 if (IsSideSwim()) dy = down_step;
20187 break;
20188 case left:
20189 dx -= step;
20190 if (IsSideSwim()) dx = left_step;
20191 break;
20192 case right:
20193 dx += step;
20194 if (IsSideSwim()) dx = right_step;
20195 break;
20196 };
20197 }
20198 450722 hero_newstep = movepix;
20199 450722 hero_newstep_diag = movepix;
20200
20201
7/16
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 448453 times.
✓ Branch 2 taken 365811 times.
✓ Branch 3 taken 84911 times.
✓ Branch 4 taken 365811 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 365811 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 365811 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
450722 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20202 {
20203 365811 dir=d2;
20204 365811 }
20205
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 84911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
84911 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20206 {
20207 dir = shiftdir;
20208 }
20209
2/2
✓ Branch 0 taken 450465 times.
✓ Branch 1 taken 257 times.
450722 if(forceRate > -1)
20210 {
20211 257 checkladder = false;
20212
2/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 245 times.
257 switch(dir)
20213 {
20214 case right:
20215 case r_up:
20216 case r_down:
20217 12 dx = zfix(forceRate) / 100;
20218 12 break;
20219 case left:
20220 case l_up:
20221 case l_down:
20222 dx = zfix(-forceRate) / 100;
20223 break;
20224 default:
20225 245 dx = 0;
20226 245 }
20227
3/3
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 12 times.
257 switch(dir)
20228 {
20229 case down:
20230 case r_down:
20231 case l_down:
20232 17 dy = zfix(forceRate) / 100;
20233 17 break;
20234 case up:
20235 case r_up:
20236 case l_up:
20237 228 dy = zfix(-forceRate) / 100;
20238 228 break;
20239 default:
20240 12 dy = 0;
20241 12 }
20242 257 }
20243
4/4
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 448268 times.
✓ Branch 2 taken 1716 times.
✓ Branch 3 taken 738 times.
450722 if (isSideViewHero() && slopeid)
20244 {
20245 738 dy += (dx * slopeid);
20246 738 }
20247
4/4
✓ Branch 0 taken 139312 times.
✓ Branch 1 taken 311410 times.
✓ Branch 2 taken 111086 times.
✓ Branch 3 taken 28226 times.
450722 if(dx == 0 && dy == 0) return;
20248
5/8
✓ Branch 0 taken 339854 times.
✓ Branch 1 taken 82642 times.
✓ Branch 2 taken 339854 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 339854 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 339854 times.
422496 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
20249 {
20250 339854 herostep();
20251
20252 //ack... don't walk if in midair! -DD
20253
11/14
✓ Branch 0 taken 337851 times.
✓ Branch 1 taken 2003 times.
✓ Branch 2 taken 337851 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 335538 times.
✓ Branch 5 taken 2313 times.
✓ Branch 6 taken 335538 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2390 times.
✓ Branch 9 taken 333148 times.
✓ Branch 10 taken 1016 times.
✓ Branch 11 taken 1374 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1016 times.
339854 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20254 {
20255 334522 action=walking; FFCore.setHeroAction(walking);
20256 334522 }
20257
20258
2/2
✓ Branch 0 taken 321950 times.
✓ Branch 1 taken 17904 times.
339854 if(++hero_count > (16*hero_animation_speed))
20259 17904 hero_count=0;
20260 339854 }
20261
1/2
✓ Branch 0 taken 82642 times.
✗ Branch 1 not taken.
82642 else if(!(frame & 1))
20262 {
20263 herostep();
20264 }
20265
20266
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 420493 times.
✓ Branch 2 taken 80639 times.
✓ Branch 3 taken 78636 times.
422496 if(charging==0 || attack!=wHammer)
20267 {
20268 501132 sprite::move(dx, dy);
20269 501132 WalkflagInfo info;
20270 501132 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
20271 501132 execute(info);
20272
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 339854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 339854 times.
✗ Branch 7 not taken.
501132 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
20273 {
20274 if (game->get_sideswim_jump() != 0)
20275 {
20276 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
20277 sfx(WAV_ZN1SPLASH,(int32_t)x);
20278 hopclk = 0;
20279 if (charging || spins) action = attacking;
20280 else action = none;
20281 }
20282 else
20283 {
20284 sprite::move(0_zf, zfix(-1*dy));
20285 }
20286 }
20287 339854 }
20288 7911148 }
20289
20290 32524807 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
20291 {
20292 32524807 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
20293 }
20294 32524807 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
20295 {
20296 32524807 WalkflagInfo ret;
20297
20298
2/2
✓ Branch 0 taken 189113 times.
✓ Branch 1 taken 32335694 times.
32524807 if (!is_in_world_bounds(wx, wy))
20299 {
20300 189113 ret.setUnwalkable(false);
20301 189113 return ret;
20302 }
20303
20304
2/2
✓ Branch 0 taken 45484 times.
✓ Branch 1 taken 32290210 times.
32335694 if(toogam)
20305 {
20306 45484 ret.setUnwalkable(false);
20307 45484 return ret;
20308 }
20309
20310
4/4
✓ Branch 0 taken 547849 times.
✓ Branch 1 taken 31742361 times.
✓ Branch 2 taken 522813 times.
✓ Branch 3 taken 25036 times.
32290210 if(blockpath && wy<(bigHitbox?80:88))
20311 {
20312 25036 ret.setUnwalkable(true);
20313 25036 return ret;
20314 }
20315
20316
4/4
✓ Branch 0 taken 507805 times.
✓ Branch 1 taken 31757369 times.
✓ Branch 2 taken 317946 times.
✓ Branch 3 taken 189859 times.
32265174 if(mblock2.active() && mblock2.hit(wx,wy,0,1,1,1))
20317 {
20318 189859 ret.setUnwalkable(true);
20319 189859 return ret;
20320 }
20321
20322
2/2
✓ Branch 0 taken 1100 times.
✓ Branch 1 taken 32074215 times.
32075315 if (collide_object(wx, wy,1, 1))
20323 {
20324 1100 ret.setUnwalkable(true);
20325 1100 return ret;
20326 }
20327
20328
18/22
✓ Branch 0 taken 15316175 times.
✓ Branch 1 taken 16758040 times.
✓ Branch 2 taken 14864682 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 14343660 times.
✓ Branch 5 taken 521022 times.
✓ Branch 6 taken 517624 times.
✓ Branch 7 taken 3398 times.
✓ Branch 8 taken 517624 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 517624 times.
✓ Branch 12 taken 2095 times.
✓ Branch 13 taken 1303 times.
✓ Branch 14 taken 281863 times.
✓ Branch 15 taken 239159 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239159 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 239159 times.
✓ Branch 20 taken 31083 times.
✓ Branch 21 taken 32043132 times.
32386520 if(isdungeon() && cur_screen<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,STANDING_Z_STATE))
20329
2/2
✓ Branch 0 taken 30442 times.
✓ Branch 1 taken 208717 times.
521022 && !get_qr(qr_FREEFORM))
20330 {
20331 31083 ret.setUnwalkable(true);
20332 31083 return ret;
20333 }
20334
20335
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32043132 times.
✓ Branch 2 taken 32043132 times.
✗ Branch 3 not taken.
32043132 bool wf = _walkflag(wx,wy,cnt,STANDING_Z_STATE);
20336
20337
6/6
✓ Branch 0 taken 15285092 times.
✓ Branch 1 taken 16758040 times.
✓ Branch 2 taken 14833599 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 6357215 times.
✓ Branch 5 taken 8476384 times.
32043132 if(isdungeon() && cur_screen<128 && !get_qr(qr_FREEFORM))
20338 {
20339
3/6
✓ Branch 0 taken 8476384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8476384 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8476384 times.
8476384 if((diagonalMovement||NO_GRIDLOCK))
20340 {
20341 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
20342
20343 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
20344 }
20345 8476384 }
20346 //All problems related to exiting water are probably here. -Z
20347
3/4
✓ Branch 0 taken 31365802 times.
✓ Branch 1 taken 677330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31365802 times.
32043132 if(action==swimming || IsSideSwim())
20348 {
20349
2/2
✓ Branch 0 taken 645181 times.
✓ Branch 1 taken 32149 times.
677330 if(!wf)
20350 {
20351 32149 bool isthissolid = false;
20352
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32149 times.
✓ Branch 4 taken 5887 times.
✓ Branch 5 taken 26262 times.
38460 if (_walkflag(x+7,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
20353
4/6
✓ Branch 0 taken 25838 times.
✓ Branch 1 taken 6311 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6311 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6311 times.
32149 || _walkflag(x+7,y+(bigHitbox?9:12),1,STANDING_Z_STATE)
20354
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6289 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6289 times.
6311 || _walkflag(x+8,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
20355
4/6
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 5887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5887 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5887 times.
32551 || _walkflag(x+8,y+(bigHitbox?9:12),1,STANDING_Z_STATE)) isthissolid = true;
20356 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
20357
20358
20359
5/6
✓ Branch 0 taken 7310 times.
✓ Branch 1 taken 24839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7310 times.
✓ Branch 4 taken 14729 times.
✓ Branch 5 taken 46086 times.
56988 if(landswim>= (get_qr(qr_DROWN) && isSwimming() ? 1
20360
2/2
✓ Branch 0 taken 2107 times.
✓ Branch 1 taken 22732 times.
24839 : (!diagonalMovement) ? 1 : (get_qr(qr_NO_HOPPING)?1:22)))
20361 {
20362 //Check for out of bounds for swimming
20363 14729 bool changehop = true;
20364
20365
5/6
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 12901 times.
✓ Branch 2 taken 1828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12828 times.
✓ Branch 5 taken 11732 times.
14729 if((diagonalMovement||NO_GRIDLOCK))
20366 {
20367
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
25729 if(wx<0||wy<0)
20368 changehop = false;
20369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 else if(wx>world_w - 8)
20370 changehop = false;
20371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73 else if(wx>world_w - 16&&cnt==2)
20372 changehop = false;
20373
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 3 times.
73 else if(wy>world_h - (show_bottom_8px ? 0 : 8))
20374 3 changehop = false;
20375 73 }
20376
3/4
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 9904 times.
✓ Branch 2 taken 11805 times.
✗ Branch 3 not taken.
11805 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
20377 //This may be where the hang-up for exiting water exists. -Z
20378 // hop out of the water
20379
2/2
✓ Branch 0 taken 9907 times.
✓ Branch 1 taken 1898 times.
11805 if(changehop)
20380 1898 ret.setHopClk(1);
20381 11805 }
20382 else
20383 {
20384
6/6
✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 19977 times.
✓ Branch 2 taken 25289 times.
✓ Branch 3 taken 20797 times.
✓ Branch 4 taken 16813 times.
✓ Branch 5 taken 8476 times.
46086 if((!(get_qr(qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
20385 {
20386
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 7515 times.
25289 if(d2==left)
20387 {
20388
4/4
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1656 times.
✓ Branch 3 taken 280 times.
3596 if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?6:11)), -1, x-1,y+(bigHitbox?6:11)) &&
20389
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1658 times.
1660 !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?9:12)), -1, x-1,y+(bigHitbox?9:12)) &&
20390
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1658 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1656 times.
1658 !_walkflag(x-1,y+(bigHitbox?6:11),1,STANDING_Z_STATE) &&
20391
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1656 times.
1656 !_walkflag(x-1,y+(bigHitbox?9:12),1,STANDING_Z_STATE))
20392 {
20393 1656 ret.setHopDir(d2);
20394 1656 ret.setIlswim(true);
20395 1656 }
20396 280 else ret.setIlswim(false);
20397 1936 }
20398
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 1764 times.
7515 else if(d2==right)
20399 {
20400
4/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 4097 times.
✓ Branch 2 taken 1654 times.
✓ Branch 3 taken 4097 times.
7405 if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?6:11)), -1, x+16,y+(bigHitbox?6:11)) &&
20401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
1654 !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?9:12)), -1, x+16,y+(bigHitbox?9:12)) &&
20402
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?6:11),1,STANDING_Z_STATE) &&
20403
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?9:12),1,STANDING_Z_STATE))
20404 {
20405 1654 ret.setHopDir(d2);
20406 1654 ret.setIlswim(true);
20407 1654 }
20408 4097 else ret.setIlswim(false);
20409 5751 }
20410
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 762 times.
1764 else if(d2==up)
20411 {
20412
4/4
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 221 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 223 times.
1303 if(!iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1) &&
20413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
541 !iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1) &&
20414
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 541 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 539 times.
541 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
20415
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 539 times.
539 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
20416 {
20417 539 ret.setHopDir(d2);
20418 539 ret.setIlswim(true);
20419 539 }
20420 223 else ret.setIlswim(false);
20421 762 }
20422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 else if(d2==down)
20423 {
20424
4/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 351 times.
✓ Branch 3 taken 651 times.
1353 if(!iswaterex_z3(MAPCOMBO(x+7,y+16), -1, x+7,y+16) &&
20425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16) &&
20426
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351 times.
351 !_walkflag(x+7,y+16,1,STANDING_Z_STATE) &&
20427
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 !_walkflag(x+8,y+16,1,STANDING_Z_STATE))
20428 {
20429 351 ret.setHopDir(d2);
20430 351 ret.setIlswim(true);
20431 351 }
20432 651 else ret.setIlswim(false);
20433 1002 }
20434 9451 }
20435
20436
2/4
✓ Branch 0 taken 30248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30248 times.
30248 if(wx<0||wy<0);
20437
2/2
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 25826 times.
30248 else if(wx > world_w - 8);
20438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25826 else if(wx > world_w - 16 &&cnt==2);
20439
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 25052 times.
25826 else if(wy > world_h - (show_bottom_8px ? 0 : 8));
20440
4/4
✓ Branch 0 taken 6428 times.
✓ Branch 1 taken 18624 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 6399 times.
25052 else if(get_qr(qr_DROWN) && !ilswim);
20441
2/2
✓ Branch 0 taken 17095 times.
✓ Branch 1 taken 1558 times.
18653 else if(iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
20442 {
20443 1558 ret.setUnwalkable(false);
20444 1558 return ret;
20445 }
20446 else
20447 {
20448 17095 ret.setUnwalkable(true);
20449 17095 return ret;
20450 }
20451 }
20452 23400 }
20453 else
20454 {
20455
4/4
✓ Branch 0 taken 595014 times.
✓ Branch 1 taken 50167 times.
✓ Branch 2 taken 56527 times.
✓ Branch 3 taken 538487 times.
645181 if (d2>=left && iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy))
20456 {
20457 538487 ret.setUnwalkable(false);
20458 538487 return ret;
20459 }
20460
6/6
✓ Branch 0 taken 50167 times.
✓ Branch 1 taken 56527 times.
✓ Branch 2 taken 10796 times.
✓ Branch 3 taken 39371 times.
✓ Branch 4 taken 38171 times.
✓ Branch 5 taken 68523 times.
106694 else if (d2<=down && iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy) && iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy))
20461 {
20462 38171 ret.setUnwalkable(false);
20463 38171 return ret;
20464 }
20465 }
20466 91923 }
20467
2/2
✓ Branch 0 taken 384504 times.
✓ Branch 1 taken 30981298 times.
31365802 else if(ladderx+laddery) // ladder is being used
20468 {
20469
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t lx = !(get_qr(qr_DROWN)&&iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,STANDING_Z_STATE)) ? zfix(wx) : x;
20470
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t ly = !(get_qr(qr_DROWN)&&iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,STANDING_Z_STATE)) ? zfix(wy) : y;
20471
20472
4/6
✓ Branch 0 taken 363296 times.
✓ Branch 1 taken 21208 times.
✓ Branch 2 taken 363296 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 363296 times.
384504 if((diagonalMovement||NO_GRIDLOCK))
20473 {
20474
2/2
✓ Branch 0 taken 13575 times.
✓ Branch 1 taken 7633 times.
21208 if(ladderdir==up)
20475 {
20476
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 4270 times.
7633 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
20477 {
20478 4270 bool temp = false;
20479
20480
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 2879 times.
4270 if(!(abs(lx-(ladderx+8))<=8))
20481 2879 temp = true;
20482
20483
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 980 times.
4270 if(cnt==2)
20484
1/2
✓ Branch 0 taken 980 times.
✗ Branch 1 not taken.
980 if(!(abs((lx+8)-(ladderx+8))<=8))
20485 temp=true;
20486
20487
2/2
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 1391 times.
4270 if(!temp)
20488 {
20489 1391 ret.setUnwalkable(false);
20490 1391 return ret;
20491 }
20492
20493
5/6
✓ Branch 0 taken 2879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 754 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 2757 times.
2879 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
20494 {
20495 2757 ret.setUnwalkable(true);
20496 2757 return ret;
20497 }
20498 122 }
20499 3485 }
20500 else
20501 {
20502
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 6555 times.
13575 if(abs(lx-(ladderx+8))<=8)
20503 {
20504
2/2
✓ Branch 0 taken 4323 times.
✓ Branch 1 taken 2232 times.
6555 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
20505 {
20506 4323 ret.setUnwalkable(false);
20507 4323 return ret;
20508 }
20509
20510
6/6
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 916 times.
✓ Branch 5 taken 869 times.
2232 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
20511 {
20512 1351 ret.setUnwalkable(true);
20513 1351 return ret;
20514 }
20515
20516
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
881 if((abs(ly-laddery+8)<=8) && d2<=down)
20517 {
20518 ret.setUnwalkable(false);
20519 return ret;
20520 }
20521 881 }
20522 }
20523 11386 } // diagonalMovement
20524 else
20525 {
20526
2/2
✓ Branch 0 taken 222358 times.
✓ Branch 1 taken 140938 times.
363296 if((d2&2)==ladderdir) // same direction
20527 {
20528
3/3
✓ Branch 0 taken 13729 times.
✓ Branch 1 taken 196539 times.
✓ Branch 2 taken 12090 times.
222358 switch(d2)
20529 {
20530 case up:
20531
2/2
✓ Branch 0 taken 8605 times.
✓ Branch 1 taken 3485 times.
12090 if(y.getInt()<=laddery)
20532 {
20533
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8605 times.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 7635 times.
16240 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,STANDING_Z_STATE) ||
20534
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7635 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7635 times.
7635 _walkflag(ladderx+8,laddery-8,1,STANDING_Z_STATE));
20535 8605 return ret;
20536
20537 }
20538
20539 [[fallthrough]];
20540 case down:
20541
2/2
✓ Branch 0 taken 9176 times.
✓ Branch 1 taken 8038 times.
17214 if(TRUNCATE_TILE(wy)==laddery)
20542 {
20543 9176 ret.setUnwalkable(false);
20544 9176 return ret;
20545 }
20546
20547 8038 break;
20548
20549 default:
20550
2/2
✓ Branch 0 taken 74354 times.
✓ Branch 1 taken 122185 times.
196539 if(TRUNCATE_TILE(wx)==ladderx)
20551 {
20552 74354 ret.setUnwalkable(false);
20553 74354 return ret;
20554 }
20555 122185 }
20556
20557
2/2
✓ Branch 0 taken 8038 times.
✓ Branch 1 taken 122185 times.
130223 if(d2<=down)
20558 {
20559
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8038 times.
✓ Branch 4 taken 1060 times.
✓ Branch 5 taken 6978 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6978 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6978 times.
8038 ret.setUnwalkable(_walkflag(ladderx,wy,1,STANDING_Z_STATE) || _walkflag(ladderx+8,wy,1,STANDING_Z_STATE));
20560 8038 return ret;
20561 }
20562
20563
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 122185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122185 times.
✓ Branch 4 taken 29654 times.
✓ Branch 5 taken 92531 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 92531 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 92531 times.
122185 ret.setUnwalkable(_walkflag(TRUNCATE_TILE(wx),wy,1,STANDING_Z_STATE) || _walkflag(TRUNCATE_TILE(wx)+8,wy,1,STANDING_Z_STATE));
20564 122185 return ret;
20565 }
20566
20567 // different dir
20568
3/8
✓ Branch 0 taken 140509 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 140509 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
140938 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
20569 {
20570 140509 ret.setUnwalkable(true);
20571 140509 return ret;
20572 }
20573
20574
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
20575 {
20576 20 ret.setUnwalkable(false);
20577 20 return ret;
20578 }
20579 }
20580 11795 }
20581
6/6
✓ Branch 0 taken 25667495 times.
✓ Branch 1 taken 5313803 times.
✓ Branch 2 taken 25284049 times.
✓ Branch 3 taken 383446 times.
✓ Branch 4 taken 6699086 times.
✓ Branch 5 taken 18584963 times.
30981298 else if(wf || isSideViewHero() || get_qr(qr_DROWN))
20582 {
20583 // see if it's a good spot for the ladder or for swimming
20584
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12396335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12396335 times.
12396335 bool unwalkablex = _walkflag(wx,wy,1,STANDING_Z_STATE); //will be used later for the ladder -DD
20585
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12396335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12396335 times.
12396335 bool unwalkablex8 = _walkflag(x+8,wy,1,STANDING_Z_STATE);
20586
20587
2/2
✓ Branch 0 taken 3562450 times.
✓ Branch 1 taken 8833885 times.
12396335 if(get_qr(qr_DROWN))
20588 {
20589 // Drowning changes the following attributes:
20590 // * Dangerous water is also walkable, so ignore the previous
20591 // definitions of unwalkablex and unwalkablex8.
20592 // * Instead, prevent the ladder from being used in the
20593 // one frame where Hero has landed on water before drowning.
20594 8833885 unwalkablex = unwalkablex8 = !iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11);
20595 8833885 }
20596
20597 // check if he can swim
20598
5/6
✓ Branch 0 taken 2582531 times.
✓ Branch 1 taken 9813804 times.
✓ Branch 2 taken 2579567 times.
✓ Branch 3 taken 2964 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2579567 times.
12396335 if(current_item(itype_flippers) && z==0 && fakez==0)
20599 {
20600 2579567 int32_t wtrx = iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy);
20601 2579567 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
20602
2/6
✓ Branch 0 taken 2579567 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2579567 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2579567 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
20603 {
20604 //ladder ignores water combos that are now walkable thanks to flippers -DD
20605
2/2
✓ Branch 0 taken 13116 times.
✓ Branch 1 taken 2566451 times.
2579567 unwalkablex = unwalkablex && (!wtrx);
20606
2/2
✓ Branch 0 taken 1358908 times.
✓ Branch 1 taken 1220659 times.
2579567 unwalkablex8 = unwalkablex8 && (!wtrx8);
20607
20608
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2579505 times.
2579567 if(landswim >= 22)
20609 {
20610 62 ret.setHopClk(2);
20611 62 ret.setUnwalkable(false);
20612 62 return ret;
20613 }
20614
8/8
✓ Branch 0 taken 2202699 times.
✓ Branch 1 taken 376806 times.
✓ Branch 2 taken 17578 times.
✓ Branch 3 taken 2185121 times.
✓ Branch 4 taken 376806 times.
✓ Branch 5 taken 2185121 times.
✓ Branch 6 taken 1912 times.
✓ Branch 7 taken 374894 times.
2579505 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20615 {
20616
4/6
✓ Branch 0 taken 12538 times.
✓ Branch 1 taken 6952 times.
✓ Branch 2 taken 12538 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12538 times.
19490 if(!(diagonalMovement||NO_GRIDLOCK))
20617 {
20618 12538 ret.setHopClk(2);
20619
20620
2/4
✓ Branch 0 taken 12538 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12538 times.
12538 if(charging || spins>5)
20621 {
20622 //if Hero is charging, he might be facing the wrong direction (we want him to
20623 //hop into the water, not in the facing direction)
20624 ret.setDir(d2);
20625 //moreover Hero can't charge in the water -DD
20626 ret.setChargeAttack();
20627 }
20628
20629 12538 ret.setUnwalkable(false);
20630 12538 return ret;
20631 }
20632
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 6391 times.
6952 else if(dir==d2)
20633 {
20634 6391 ret.setIlswim(true);
20635 6391 ladderx = 0;
20636 6391 laddery = 0;
20637 6391 }
20638 6952 }
20639 2566967 }
20640 2566967 }
20641
20642 // check if he can use the ladder
20643 // "Allow Ladder Anywhere" is toggled by fLADDER
20644
2/2
✓ Branch 0 taken 9371857 times.
✓ Branch 1 taken 3011878 times.
12383735 if(can_deploy_ladder())
20645 // laddersetup
20646 {
20647 // Check if there's water to use the ladder over
20648 3011878 bool wtrx = (iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy) != 0);
20649 3011878 bool wtrx8 = (iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy) != 0);
20650 3011878 int32_t ldrid = current_item_id(itype_ladder);
20651
1/2
✓ Branch 0 taken 3011878 times.
✗ Branch 1 not taken.
3011878 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
20652
20653
4/4
✓ Branch 0 taken 3001927 times.
✓ Branch 1 taken 9951 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 3001862 times.
3011878 if(wtrx || wtrx8)
20654 {
20655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10016 times.
10016 if(isSideViewHero())
20656 {
20657 wtrx = !_walkflag(wx, wy+8, 1,STANDING_Z_STATE) && !_walkflag(wx, wy, 1,STANDING_Z_STATE) && dir!=down;
20658 wtrx8 = !_walkflag(wx+8, wy+8, 1,STANDING_Z_STATE) && !_walkflag(wx+8, wy, 1,STANDING_Z_STATE) && dir!=down;
20659 }
20660 // * walk on half-water using the ladder instead of using flippers.
20661 // * otherwise, walk on ladder(+hookshot) combos.
20662
3/8
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 9383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 633 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10016 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
20663 {
20664
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 502 times.
633 if(!get_qr(qr_OLD_210_WATER))
20665 {
20666 //if Hero could swim on a tile instead of using the ladder,
20667 //refuse to use the ladder to step over that tile. -DD
20668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
20669
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 496 times.
502 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
20670 502 }
20671 633 }
20672 10016 }
20673 else
20674 {
20675 // No water; check other things
20676
20677 //Check pits
20678
2/2
✓ Branch 0 taken 3000835 times.
✓ Branch 1 taken 1027 times.
3001862 if(ladderpits)
20679 {
20680 1027 int32_t pit_cmb = getpitfall(wx,wy);
20681
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20682 1027 pit_cmb = getpitfall(x+8,wy);
20683
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
20684 1027 }
20685
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 3000835 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
3001862 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
20686 {
20687 3001862 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
20688
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 3001676 times.
3001862 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20689 3001862 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
20690
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 3001570 times.
3001862 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
20691 3001862 }
20692 }
20693
20694
2/2
✓ Branch 0 taken 6023756 times.
✓ Branch 1 taken 3011878 times.
9035634 for (int32_t i = 0; i <= 1; ++i)
20695 {
20696
2/2
✓ Branch 0 taken 5649190 times.
✓ Branch 1 taken 374566 times.
6023756 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20697 {
20698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5649190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5649190 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,i)) wtrx = false;
20699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5649190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5649190 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,i)) wtrx8 = false;
20700 5649190 }
20701 else
20702 {
20703
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 374307 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
374566 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,i)) wtrx = false;
20704
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 374329 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
374566 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,i)) wtrx8 = false;
20705 }
20706 6023756 }
20707
2/2
✓ Branch 0 taken 2062592 times.
✓ Branch 1 taken 949286 times.
3011878 bool walkwater = (get_qr(qr_DROWN) && !iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy));
20708
20709
4/6
✓ Branch 0 taken 2202554 times.
✓ Branch 1 taken 809324 times.
✓ Branch 2 taken 2202554 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2202554 times.
3011878 if((diagonalMovement||NO_GRIDLOCK))
20710 {
20711
2/2
✓ Branch 0 taken 160130 times.
✓ Branch 1 taken 649194 times.
809324 if(d2==dir)
20712 {
20713 649194 int32_t c = walkwater ? 0:8;
20714 649194 int32_t b = walkwater ? 8:0;
20715
20716
2/2
✓ Branch 0 taken 422656 times.
✓ Branch 1 taken 226538 times.
649194 if(d2>=left)
20717 {
20718 // If the difference between wy and y is small enough
20719
4/4
✓ Branch 0 taken 126986 times.
✓ Branch 1 taken 295670 times.
✓ Branch 2 taken 422498 times.
✓ Branch 3 taken 158 times.
422656 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
20720 {
20721 // Don't activate the ladder if it would be entirely
20722 // over water and Hero has the flippers. This isn't
20723 // a good way to do this, but it's too risky
20724 // to make big changes to this stuff.
20725 158 bool deployLadder=true;
20726 158 int32_t lx= TRUNCATE_TILE(wx);
20727
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2 times.
158 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex_z3(MAPCOMBO(lx+8, y+8), -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
20728 {
20729
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex_z3(MAPCOMBO(lx, y), -1, lx, y) &&
20730 iswaterex_z3(MAPCOMBO(lx+15, y), -1, lx+15, y) &&
20731 iswaterex_z3(MAPCOMBO(lx, y+15), -1, lx, y+15) &&
20732 iswaterex_z3(MAPCOMBO(lx+15, y+15), -1, lx+15, y+15))
20733 deployLadder=false;
20734 2 }
20735
1/2
✓ Branch 0 taken 158 times.
✗ Branch 1 not taken.
158 if(deployLadder)
20736 {
20737 158 ladderx = TRUNCATE_TILE(wx);
20738 158 laddery = y;
20739 158 ladderdir = left;
20740 158 ladderstart = d2;
20741 158 ret.setUnwalkable(laddery!=y.getInt());
20742 158 return ret;
20743 }
20744 }
20745 422498 }
20746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226538 times.
226538 else if(d2<=down)
20747 {
20748 // If the difference between wx and x is small enough
20749
4/4
✓ Branch 0 taken 89635 times.
✓ Branch 1 taken 136903 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 226451 times.
226538 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
20750 {
20751 87 ladderx = x;
20752 87 laddery = TRUNCATE_TILE(wy);
20753 87 ladderdir = up;
20754 87 ladderstart = d2;
20755 87 ret.setUnwalkable(ladderx!=x.getInt());
20756 87 return ret;
20757 }
20758
20759
2/2
✓ Branch 0 taken 89594 times.
✓ Branch 1 taken 136857 times.
226451 if(cnt==2)
20760 {
20761
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136857 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 136840 times.
136857 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
20762 {
20763 17 ladderx = x;
20764 17 laddery = TRUNCATE_TILE(wy);
20765 17 ladderdir = up;
20766 17 ladderstart = d2;
20767 17 ret.setUnwalkable(ladderx!=x.getInt());
20768 17 return ret;
20769 }
20770 136840 }
20771 226434 }
20772 648932 }
20773 809062 }
20774 else
20775 {
20776
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 116610 times.
✓ Branch 5 taken 2085944 times.
2202554 bool flgx = _walkflag(wx,wy,1,STANDING_Z_STATE) && !wtrx; // Solid, and not steppable
20777
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 2015835 times.
✓ Branch 5 taken 186719 times.
2202554 bool flgx8 = _walkflag(x+8,wy,1,STANDING_Z_STATE) && !wtrx8; // Solid, and not steppable
20778
20779
2/2
✓ Branch 0 taken 2039953 times.
✓ Branch 1 taken 162601 times.
2202626 if((d2>=left && wtrx)
20780 // Deploy the ladder vertically even if Hero is only half on water.
20781
8/8
✓ Branch 0 taken 18496 times.
✓ Branch 1 taken 2021457 times.
✓ Branch 2 taken 162601 times.
✓ Branch 3 taken 2021457 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 161379 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 162529 times.
2202554 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
20782 {
20783
4/4
✓ Branch 0 taken 17936 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 697 times.
✓ Branch 3 taken 17239 times.
18496 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
20784 1257 ladderdir = up;
20785 else
20786 17239 ladderdir = left;
20787
20788
2/2
✓ Branch 0 taken 17239 times.
✓ Branch 1 taken 1257 times.
18496 if(ladderdir==up)
20789 {
20790 1257 ladderx = TRUNCATE_HALF_TILE(x.getInt());
20791 1257 laddery = TRUNCATE_TILE(wy);
20792 1257 }
20793 else
20794 {
20795 17239 ladderx = TRUNCATE_TILE(wx);
20796 17239 laddery = TRUNCATE_HALF_TILE(y.getInt());
20797
20798 }
20799
20800 18496 ret.setUnwalkable(false);
20801 18496 return ret;
20802 }
20803 }
20804 2993120 }
20805 12364977 }
20806
20807 31053658 ret.setUnwalkable(wf);
20808 31053658 return ret;
20809 32534711 }
20810
20811 // Only checks for moving blocks. Apparently this is a thing we need.
20812 3051885 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
20813 {
20814 3051885 HeroClass::WalkflagInfo ret;
20815
2/2
✓ Branch 0 taken 47939 times.
✓ Branch 1 taken 3003946 times.
3051885 if (!mblock2.active()) //Without this, weird swimming behaviors happen.
20816 {
20817 3003946 ret.setFlags(~1);
20818 3003946 ret.setHopDir(-1);
20819 3003946 }
20820
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 3049077 times.
3051885 if(toogam) return ret;
20821
2/2
✓ Branch 0 taken 3001138 times.
✓ Branch 1 taken 47939 times.
3049077 if (mblock2.active())
20822 47939 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
20823
2/2
✓ Branch 0 taken 3048827 times.
✓ Branch 1 taken 250 times.
3049077 if (collide_object(wx, wy,1, 1))
20824 250 ret.setUnwalkable(true);
20825 3049077 return ret;
20826 3051885 }
20827
20828 14091140 bool HeroClass::checksoliddamage()
20829 {
20830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14091140 times.
14091140 if(toogam) return false;
20831
20832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14091140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14091140 if (get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && get_qr(qr_NOSOLIDDAMAGECOMBOS)) return false; //no point checking if both of these rules are on
20833
20834
2/4
✓ Branch 0 taken 14091140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14091140 times.
14091140 if(z!=0||fakez!=0) return false;
20835 14091140 int32_t bx = x.getInt();
20836 14091140 int32_t by = y.getInt();
20837 14091140 int32_t initk = 0;
20838
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3474039 times.
✓ Branch 2 taken 2822006 times.
✓ Branch 3 taken 3768622 times.
✓ Branch 4 taken 4026473 times.
14091140 switch(dir)
20839 {
20840 case up:
20841
20842
2/2
✓ Branch 0 taken 84937 times.
✓ Branch 1 taken 3389102 times.
3474039 by-=get_qr(qr_NEW_HERO_MOVEMENT2)?(bigHitbox ? 4 : -4):(bigHitbox ? 1 : -7);
20843
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3390557 times.
3474039 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
20844
2/2
✓ Branch 0 taken 3389200 times.
✓ Branch 1 taken 1357 times.
3390557 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
20845
2/2
✓ Branch 0 taken 3473925 times.
✓ Branch 1 taken 114 times.
3474039 if(by<0)
20846 {
20847 114 return false;
20848 }
20849 3473925 break;
20850
20851 case down:
20852
20853 2822006 by+=20;
20854
2/2
✓ Branch 0 taken 27162 times.
✓ Branch 1 taken 2794844 times.
2822006 if (by >= world_h)
20855 {
20856 27162 return false;
20857 }
20858
20859 2794844 break;
20860
20861 case left:
20862 3768622 bx-=get_qr(qr_NEW_HERO_MOVEMENT2)?1:4;
20863
2/2
✓ Branch 0 taken 119761 times.
✓ Branch 1 taken 3648861 times.
3768622 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
20864
2/2
✓ Branch 0 taken 3647141 times.
✓ Branch 1 taken 1720 times.
3648861 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
20865
4/4
✓ Branch 0 taken 3683976 times.
✓ Branch 1 taken 84646 times.
✓ Branch 2 taken 119761 times.
✓ Branch 3 taken 3564215 times.
3768622 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
20866 {
20867 3564215 by+=8;
20868 3564215 initk = 1;
20869 3564215 }
20870
2/2
✓ Branch 0 taken 3748174 times.
✓ Branch 1 taken 20448 times.
3768622 if(bx<0)
20871 {
20872 20448 return false;
20873 }
20874
20875 3748174 break;
20876
20877 case right:
20878 4026473 bx+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
20879
2/2
✓ Branch 0 taken 118008 times.
✓ Branch 1 taken 3908465 times.
4026473 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
20880
2/2
✓ Branch 0 taken 3905137 times.
✓ Branch 1 taken 3328 times.
3908465 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
20881
4/4
✓ Branch 0 taken 3931614 times.
✓ Branch 1 taken 94859 times.
✓ Branch 2 taken 118008 times.
✓ Branch 3 taken 3813606 times.
4026473 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
20882 {
20883 3813606 by+=8;
20884 3813606 initk = 1;
20885 3813606 }
20886
2/2
✓ Branch 0 taken 29270 times.
✓ Branch 1 taken 3997203 times.
4026473 if (bx >= world_w)
20887 {
20888 29270 return false;
20889 }
20890
20891 3997203 break;
20892 }
20893
20894 14014146 newcombo const& cmb = combobuf[MAPCOMBO(bx, by)];
20895 14014146 int32_t t = cmb.type;
20896
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 14014030 times.
14014146 if(cmb.only_gentrig)
20897 116 t = cNONE;
20898 14014146 int32_t initbx = bx;
20899 14014146 int32_t initby = by;
20900
20901 // Unlike push blocks, damage combos should be tested on layers 2 and under
20902
2/2
✓ Branch 0 taken 25578970 times.
✓ Branch 1 taken 14014131 times.
39593101 for(int32_t i=(get_qr(qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
20903 {
20904 25578970 bx = initbx;
20905 25578970 by = initby;
20906
2/2
✓ Branch 0 taken 7733663 times.
✓ Branch 1 taken 17845307 times.
25578970 if (!get_qr(qr_NOSOLIDDAMAGECOMBOS))
20907 {
20908
2/2
✓ Branch 0 taken 16549577 times.
✓ Branch 1 taken 42376384 times.
58925961 for (int32_t k = initk; k <= 2; k++)
20909 {
20910 42376384 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, i);
20911 42376384 auto& cmb = rpos_handle.combo();
20912 42376384 t = cmb.type;
20913
2/2
✓ Branch 0 taken 42376039 times.
✓ Branch 1 taken 345 times.
42376384 if(cmb.only_gentrig)
20914 345 t = cNONE;
20915 // Solid damage combos use pushing>0, hence the code is here.
20916
9/10
✓ Branch 0 taken 2298993 times.
✓ Branch 1 taken 40077391 times.
✓ Branch 2 taken 76893 times.
✓ Branch 3 taken 2222100 times.
✓ Branch 4 taken 74004 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 1566 times.
✓ Branch 7 taken 72438 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1566 times.
42376384 if (!get_qr(qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
20917 {
20918
13/16
✓ Branch 0 taken 42343576 times.
✓ Branch 1 taken 28353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28353 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28353 times.
✓ Branch 6 taken 1265 times.
✓ Branch 7 taken 27088 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1096 times.
✓ Branch 10 taken 67 times.
✓ Branch 11 taken 102 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 67 times.
✓ Branch 14 taken 42371862 times.
✓ Branch 15 taken 67 times.
42371929 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,STANDING_Z_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting)
20919 {
20920 // Bite Hero
20921
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8 times.
67 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
20922 59 }
20923 42371921 }
20924
2/2
✓ Branch 0 taken 22659953 times.
✓ Branch 1 taken 19716423 times.
42376376 if (dir < left) bx += (k % 2) ? 7 : 8;
20925 19716423 else by += (k % 2) ? 7 : 8;
20926
2/2
✓ Branch 0 taken 42309268 times.
✓ Branch 1 taken 67108 times.
42376376 if (!is_in_world_bounds(bx, by)) break;
20927
2/2
✓ Branch 0 taken 41080654 times.
✓ Branch 1 taken 1228614 times.
42309268 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) break;
20928 41080654 }
20929 17845299 }
20930
4/6
✓ Branch 0 taken 479796 times.
✓ Branch 1 taken 25099166 times.
✓ Branch 2 taken 479796 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 446811 times.
26025773 if(isSideViewHero() && !get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && // Check for sideview damage combos
20931
3/4
✓ Branch 0 taken 446811 times.
✓ Branch 1 taken 32985 times.
✓ Branch 2 taken 446811 times.
✗ Branch 3 not taken.
479796 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
20932 {
20933
2/2
✓ Branch 0 taken 35562 times.
✓ Branch 1 taken 411249 times.
446811 if (get_qr(qr_LESS_AWFUL_SIDESPIKES))
20934 {
20935
2/6
✓ Branch 0 taken 35562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35562 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35562 if (on_sideview_solid_oldpos(this) && (!getOnSideviewLadder() || DrunkDown()))
20936 {
20937
4/4
✓ Branch 0 taken 35558 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 35560 times.
✓ Branch 3 taken 2 times.
35562 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
20938 {
20939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
20940 }
20941 35560 }
20942
1/2
✓ Branch 0 taken 35560 times.
✗ Branch 1 not taken.
35560 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
20943 35560 }
20944 else
20945 {
20946 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
20947
1/2
✓ Branch 0 taken 411249 times.
✗ Branch 1 not taken.
411249 if ( get_qr(qr_OLDSIDEVIEWSPIKES ) )
20948 {
20949
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 5 times.
822498 if (checkdamagecombos(x+8-(zfix)(hero_scr->csensitive),
20950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
411249 x+8+(zc_max(hero_scr->csensitive-1,0)),
20951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
411249 y+17-(get_qr(qr_LTTPCOLLISION)?hero_scr->csensitive:(hero_scr->csensitive+1)/2),
20952
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 411249 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 411249 times.
411249 y+17+zc_max((get_qr(qr_LTTPCOLLISION)?hero_scr->csensitive:(hero_scr->csensitive+1)/2)-1,0), i-1, true))
20953 5 return true;
20954 411244 }
20955 else //2.50.1 and later
20956 {
20957 if(checkdamagecombos(x+4, x+12, y+16, y+24))
20958 return true;
20959 }
20960 }
20961
20962 446804 }
20963 25578955 }
20964
20965 14014131 return false;
20966 14091140 }
20967 14283254 void HeroClass::checkpushblock()
20968 {
20969
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268301 times.
14283254 if(toogam) return;
20970
20971
3/4
✓ Branch 0 taken 14249193 times.
✓ Branch 1 taken 19108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14249193 times.
14268301 if(z!=0||fakez!=0) return;
20972
20973 // Return early in some cases..
20974 14249193 bool earlyReturn=false;
20975
20976
5/6
✓ Branch 0 taken 9724059 times.
✓ Branch 1 taken 4525134 times.
✓ Branch 2 taken 9724059 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10961450 times.
✓ Branch 5 taken 3287743 times.
14249193 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
20977
2/2
✓ Branch 0 taken 7098964 times.
✓ Branch 1 taken 3862486 times.
10961450 if(x.getInt()&15) earlyReturn=true;
20978
20979
4/4
✓ Branch 0 taken 319027 times.
✓ Branch 1 taken 13930166 times.
✓ Branch 2 taken 160974 times.
✓ Branch 3 taken 158053 times.
14249193 if(isSideViewHero() && !on_sideview_solid_oldpos(this)) return;
20980
20981 14091140 int32_t bx = TRUNCATE_TILE(x.getInt());
20982 14091140 int32_t by = TRUNCATE_TILE(y.getInt());
20983
20984
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3474039 times.
✓ Branch 2 taken 2822006 times.
✓ Branch 3 taken 3768622 times.
✓ Branch 4 taken 4026473 times.
14091140 switch(dir)
20985 {
20986 case up:
20987
2/2
✓ Branch 0 taken 118811 times.
✓ Branch 1 taken 3355228 times.
3474039 if(y<16)
20988 {
20989 118811 earlyReturn=true;
20990 118811 break;
20991 }
20992
20993
3/4
✓ Branch 0 taken 585744 times.
✓ Branch 1 taken 2769484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585744 times.
3355228 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20994
20995
2/2
✓ Branch 0 taken 1945083 times.
✓ Branch 1 taken 1410145 times.
3355228 if((int32_t)x&8) bx+=16;
20996
20997 3355228 break;
20998
20999 case down:
21000
2/2
✓ Branch 0 taken 232784 times.
✓ Branch 1 taken 2589222 times.
2822006 if(y>world_h-48)
21001 {
21002 232784 earlyReturn=true;
21003 232784 break;
21004 }
21005 else
21006 {
21007 2589222 by+=16;
21008
21009
2/2
✓ Branch 0 taken 1657305 times.
✓ Branch 1 taken 931917 times.
2589222 if((int32_t)x&8) bx+=16;
21010 }
21011
21012 2589222 break;
21013
21014 case left:
21015
2/2
✓ Branch 0 taken 198553 times.
✓ Branch 1 taken 3570069 times.
3768622 if(x<32)
21016 {
21017 198553 earlyReturn=true;
21018 198553 break;
21019 }
21020 else
21021 {
21022 3570069 bx-=16;
21023
21024
2/2
✓ Branch 0 taken 2163271 times.
✓ Branch 1 taken 1406798 times.
3570069 if(y.getInt()&8)
21025 {
21026 1406798 by+=16;
21027 1406798 }
21028 }
21029
21030 3570069 break;
21031
21032 case right:
21033
2/2
✓ Branch 0 taken 208438 times.
✓ Branch 1 taken 3818035 times.
4026473 if(x>world_w-48)
21034 {
21035 208438 earlyReturn=true;
21036 208438 break;
21037 }
21038 else
21039 {
21040 3818035 bx+=16;
21041
21042
2/2
✓ Branch 0 taken 2330975 times.
✓ Branch 1 taken 1487060 times.
3818035 if(y.getInt()&8)
21043 {
21044 1487060 by+=16;
21045 1487060 }
21046 }
21047
21048 3818035 break;
21049 }
21050
21051
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 14091125 times.
14091140 if (checksoliddamage()) return;
21052
21053
2/2
✓ Branch 0 taken 7397434 times.
✓ Branch 1 taken 6693691 times.
14091125 if(earlyReturn)
21054 7397434 return;
21055
21056 6693691 int itemid=current_item_id(itype_bracelet);
21057 6693691 rpos_t rpos = COMBOPOS_REGION(bx, by);
21058 6693691 size_t combopos = RPOS_TO_POS(rpos);
21059
21060
2/2
✓ Branch 0 taken 2802635 times.
✓ Branch 1 taken 3891056 times.
6693691 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & item_flag1);
21061
2/2
✓ Branch 0 taken 3891056 times.
✓ Branch 1 taken 2802635 times.
6693691 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
21062
2/2
✓ Branch 0 taken 1716416 times.
✓ Branch 1 taken 10138260 times.
11854676 for(int lyr = 2; lyr >= 0; --lyr) //Top-down, in case of stacked push blocks
21063 {
21064
4/4
✓ Branch 0 taken 6437381 times.
✓ Branch 1 taken 3700879 times.
✓ Branch 2 taken 1465628 times.
✓ Branch 3 taken 4971753 times.
10138260 if(get_qr(qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
21065
4/4
✓ Branch 0 taken 3443869 times.
✓ Branch 1 taken 1722638 times.
✓ Branch 2 taken 90987 times.
✓ Branch 3 taken 3352882 times.
5166507 if(lyr && !get_qr(qr_PUSHBLOCK_LAYER_1_2))
21066 3352882 continue;
21067 1813625 auto rpos_handle = get_rpos_handle(rpos, lyr);
21068 1813625 cpos_info& cpinfo = rpos_handle.info();
21069 1813625 mapscr* m = rpos_handle.scr;
21070
2/2
✓ Branch 0 taken 91723 times.
✓ Branch 1 taken 1721902 times.
1813625 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
21071 1813625 newcombo const& cmb = combobuf[cid];
21072 1813625 int f = MAPFLAG2(lyr-1,bx,by);
21073 1813625 int f2 = cmb.flag;
21074 1813625 int t = cmb.type;
21075
21076
6/6
✓ Branch 0 taken 1697853 times.
✓ Branch 1 taken 115772 times.
✓ Branch 2 taken 1693320 times.
✓ Branch 3 taken 4533 times.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 1690856 times.
3504481 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
21077
2/2
✓ Branch 0 taken 1689940 times.
✓ Branch 1 taken 916 times.
1690856 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
21078 1813625 int heavy = 0;
21079
4/4
✓ Branch 0 taken 1808356 times.
✓ Branch 1 taken 5269 times.
✓ Branch 2 taken 15070 times.
✓ Branch 3 taken 1793286 times.
1813625 if(t==cPUSH_HW || t==cPUSH_HEAVY)
21080 20339 heavy = 1;
21081
4/4
✓ Branch 0 taken 1789389 times.
✓ Branch 1 taken 3897 times.
✓ Branch 2 taken 2464 times.
✓ Branch 3 taken 1786925 times.
1793286 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
21082 6361 heavy = 2;
21083
2/2
✓ Branch 0 taken 1786009 times.
✓ Branch 1 taken 916 times.
1786925 else if(t == cPUSHBLOCK)
21084 916 heavy = cmb.attribytes[0];
21085
21086
6/6
✓ Branch 0 taken 122033 times.
✓ Branch 1 taken 1691592 times.
✓ Branch 2 taken 39487 times.
✓ Branch 3 taken 82546 times.
✓ Branch 4 taken 3776 times.
✓ Branch 5 taken 35711 times.
1813625 if(waitblock && (pushing<16 || hasMainGuy(m->screen))) continue;
21087
21088
8/8
✓ Branch 0 taken 1705803 times.
✓ Branch 1 taken 21500 times.
✓ Branch 2 taken 18610 times.
✓ Branch 3 taken 2890 times.
✓ Branch 4 taken 3028 times.
✓ Branch 5 taken 15582 times.
✓ Branch 6 taken 6293 times.
✓ Branch 7 taken 1721010 times.
1764385 if(heavy && (itemid<0 || glove->power < heavy ||
21089
3/4
✓ Branch 0 taken 12682 times.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2900 times.
21875 (limitedpush && usecounts[itemid] >= zc_max(1, glove->misc3)))) continue;
21090
21091 1721010 bool doit=false;
21092 1721010 bool changecombo=false;
21093
21094 1721010 int blockdir = dir;
21095
1/2
✓ Branch 0 taken 1721010 times.
✗ Branch 1 not taken.
1721010 if(blockdir > 3) blockdir = Y_DIR(dir);
21096
6/6
✓ Branch 0 taken 916 times.
✓ Branch 1 taken 1720094 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 476 times.
✓ Branch 5 taken 303 times.
1721010 if(t == cPUSHBLOCK && (get_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING) || (f!=mfPUSHED)))
21097 {
21098
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 183 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 135 times.
613 switch(blockdir)
21099 {
21100 case up:
21101 74 doit = cmb.usrflags & cflag1;
21102 74 break;
21103 case down:
21104 183 doit = cmb.usrflags & cflag2;
21105 183 break;
21106 case left:
21107 221 doit = cmb.usrflags & cflag3;
21108 221 break;
21109 case right:
21110 135 doit = cmb.usrflags & cflag4;
21111 135 break;
21112 }
21113 613 bool cancel_opp = (cmb.usrflags & cflag9);
21114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613 times.
613 if(cmb.usrflags & cflag5) //Separate directions
21115 {
21116 int limit = cmb.attribytes[4+blockdir];
21117 if(limit || (cmb.usrflags & cflag9)) // don't limit if limit should be infinite
21118 {
21119 int pushes = cpinfo.pushes[blockdir];
21120 if(cancel_opp)
21121 pushes -= cpinfo.pushes[oppositeDir[blockdir]];
21122 if(pushes >= limit)
21123 doit = false;
21124 }
21125 }
21126 else
21127 {
21128
1/2
✓ Branch 0 taken 613 times.
✗ Branch 1 not taken.
613 if(int limit = cmb.attribytes[4])
21129 {
21130 if(cpinfo.sumpush() >= limit)
21131 doit = false;
21132 }
21133
1/2
✓ Branch 0 taken 613 times.
✗ Branch 1 not taken.
613 else if(cmb.usrflags & cflag9)
21134 doit = false;
21135 }
21136 613 }
21137 else
21138 {
21139
2/2
✓ Branch 0 taken 1711947 times.
✓ Branch 1 taken 8450 times.
1720397 if(is_push_flag(f,dir))
21140 {
21141 8450 doit=true;
21142 8450 }
21143
21144
7/8
✓ Branch 0 taken 1719661 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 1719661 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 1719937 times.
✓ Branch 6 taken 1719138 times.
✓ Branch 7 taken 523 times.
3439598 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
21145
3/4
✓ Branch 0 taken 1719649 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1719649 times.
✗ Branch 3 not taken.
1719937 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
21146
3/4
✓ Branch 0 taken 1719649 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1719649 times.
✗ Branch 3 not taken.
1719937 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
21147
3/4
✓ Branch 0 taken 1719335 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 1719335 times.
✗ Branch 3 not taken.
1719381 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
21148
3/4
✓ Branch 0 taken 1719280 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 1719280 times.
✗ Branch 3 not taken.
1719347 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
21149
3/4
✓ Branch 0 taken 1719274 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 1719274 times.
✗ Branch 3 not taken.
1719347 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
21150
2/2
✓ Branch 0 taken 1718947 times.
✓ Branch 1 taken 254 times.
1719661 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
21151 {
21152 523 changecombo=true;
21153 523 doit=true;
21154 523 }
21155 }
21156
21157
2/2
✓ Branch 0 taken 882780 times.
✓ Branch 1 taken 837494 times.
1720274 if(get_qr(qr_SOLIDBLK))
21158 {
21159
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 243882 times.
✓ Branch 2 taken 203524 times.
✓ Branch 3 taken 170337 times.
✓ Branch 4 taken 219751 times.
837494 switch(blockdir)
21160 {
21161 case up:
21162
3/4
✓ Branch 0 taken 243882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 243874 times.
243882 if(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)
21163 8 break; // ignore solidity for BLOCKHOLE flagged combos
21164
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 243874 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 243874 times.
✓ Branch 4 taken 98189 times.
✓ Branch 5 taken 145685 times.
243874 if(_walkflag(bx,by-8,2,STANDING_Z_STATE))
21165 98189 doit = false;
21166
5/8
✓ Branch 0 taken 145541 times.
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 144 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 145685 times.
✗ Branch 7 not taken.
145685 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx,by-16,2,STANDING_Z_STATE))
21167 doit = false; // top half wasn't checked before...
21168 243874 break;
21169
21170 case down:
21171
3/4
✓ Branch 0 taken 203524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 203514 times.
203524 if(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)
21172 10 break; // ignore solidity for BLOCKHOLE flagged combos
21173
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203514 times.
✓ Branch 2 taken 203514 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92112 times.
✓ Branch 5 taken 111402 times.
203514 if(_walkflag(bx,by+24,2,STANDING_Z_STATE))
21174 92112 doit = false;
21175
5/8
✓ Branch 0 taken 111387 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 111402 times.
✗ Branch 7 not taken.
111402 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx,by+16,2,STANDING_Z_STATE))
21176 doit = false; // top half wasn't checked before...
21177 203514 break;
21178
21179 case left:
21180
3/4
✓ Branch 0 taken 170337 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 170321 times.
170337 if(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)
21181 16 break; // ignore solidity for BLOCKHOLE flagged combos
21182
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 170321 times.
✓ Branch 2 taken 170321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93857 times.
✓ Branch 5 taken 76464 times.
170321 if(_walkflag(bx-16,by+8,2,STANDING_Z_STATE))
21183 93857 doit = false;
21184
6/8
✓ Branch 0 taken 76386 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 76458 times.
✓ Branch 7 taken 6 times.
76464 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx-16,by,2,STANDING_Z_STATE))
21185 6 doit = false; // top half wasn't checked before...
21186 170321 break;
21187
21188 case right:
21189
3/4
✓ Branch 0 taken 219751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 219704 times.
219751 if(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)
21190 47 break; // ignore solidity for BLOCKHOLE flagged combos
21191
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 219704 times.
✓ Branch 2 taken 219704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119424 times.
✓ Branch 5 taken 100280 times.
219704 if(_walkflag(bx+16,by+8,2,STANDING_Z_STATE))
21192 119424 doit = false;
21193
5/8
✓ Branch 0 taken 100235 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 100280 times.
✗ Branch 7 not taken.
100280 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx+16,by,2,STANDING_Z_STATE))
21194 doit = false; // top half wasn't checked before...
21195 219704 break;
21196 }
21197 837494 }
21198
21199
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 610093 times.
✓ Branch 2 taken 502060 times.
✓ Branch 3 taken 276977 times.
✓ Branch 4 taken 331144 times.
1720274 switch(blockdir)
21200 {
21201 case up:
21202
4/4
✓ Branch 0 taken 608853 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 608513 times.
610093 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
21203
21204 610093 break;
21205
21206 case down:
21207
4/4
✓ Branch 0 taken 500820 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 500442 times.
502060 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
21208
21209 502060 break;
21210
21211 case left:
21212
4/4
✓ Branch 0 taken 276101 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 275891 times.
276977 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
21213
21214 276977 break;
21215
21216 case right:
21217
4/4
✓ Branch 0 taken 329798 times.
✓ Branch 1 taken 1346 times.
✓ Branch 2 taken 377 times.
✓ Branch 3 taken 329421 times.
331144 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
21218
21219 331144 break;
21220 }
21221
21222
2/2
✓ Branch 0 taken 1715488 times.
✓ Branch 1 taken 4786 times.
1720274 if(doit)
21223 {
21224
2/2
✓ Branch 0 taken 4733 times.
✓ Branch 1 taken 53 times.
4786 if(limitedpush)
21225 53 ++usecounts[itemid];
21226
21227 // for(int32_t i=0; i<1; i++)
21228
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 4129 times.
4786 if(!mblock2.active())
21229 {
21230
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 3608 times.
4129 if(is_push_flag(f,dir)) // Only erase push flags, because only push flags should be copied in the block code.
21231 3608 m->sflag[combopos] = 0;
21232
21233 4129 mblock2.blockLayer = lyr;
21234
21235
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 3870 times.
4129 if(t == cPUSHBLOCK)
21236 {
21237 259 zfix blockstep = 0.5;
21238
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 205 times.
259 if(cmb.attrishorts[0] > 0)
21239 205 blockstep = zslongToFix(cmb.attrishorts[0]*100);
21240 259 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
21241 259 mblock2.blockinfo = cpinfo;
21242 259 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
21243 259 cpinfo.clearInfo();
21244
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 205 times.
259 if(cmb.attribytes[1])
21245 205 sfx(cmb.attribytes[1],(int32_t)x);
21246 259 }
21247 else
21248 {
21249 3870 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
21250
21251
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 1062 times.
3870 if(get_qr(qr_MORESOUNDS))
21252 1062 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
21253 }
21254 4129 }
21255 4786 break;
21256 }
21257 1715488 }
21258 14282518 }
21259
21260 848 bool usekey()
21261 {
21262 848 int32_t itemid = current_item_id(itype_magickey);
21263
21264
3/4
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
848 if(itemid<0 ||
21265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21266 : itemsbuf[itemid].power!=dlevel))
21267 {
21268
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 668 times.
788 if(game->lvlkeys[dlevel]!=0)
21269 {
21270 120 game->lvlkeys[dlevel]--;
21271 //run script for level key item
21272 120 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
21273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9150 times.
9150 for ( int32_t q = 0; q < MAXITEMS; ++q )
21274 {
21275
2/2
✓ Branch 0 taken 9030 times.
✓ Branch 1 taken 120 times.
9150 if ( itemsbuf[q].family == itype_lkey )
21276 {
21277 120 key_item = q; break;
21278 }
21279 9030 }
21280
21281
2/8
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
120 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21282 {
21283 int i = key_item;
21284 FFCore.reset_script_engine_data(ScriptType::Item, i);
21285 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21286 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21287 }
21288 120 return true;
21289 }
21290 else
21291 {
21292
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 332 times.
668 if(game->get_keys()==0)
21293 {
21294 332 return false;
21295 }
21296 else
21297 {
21298 //run script for key item
21299 336 int32_t key_item = 0; //current_item_id(itype_key); //not possible
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 for ( int32_t q = 0; q < MAXITEMS; ++q )
21301 {
21302
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 336 times.
3360 if ( itemsbuf[q].family == itype_key )
21303 {
21304 336 key_item = q; break;
21305 }
21306 3024 }
21307
2/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
336 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21308 {
21309 int i = key_item;
21310 FFCore.reset_script_engine_data(ScriptType::Item, i);
21311 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21312 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21313 }
21314 336 game->change_keys(-1);
21315 }
21316 }
21317 336 }
21318
21319 396 return true;
21320 848 }
21321
21322 11 bool canUseKey(int32_t num)
21323 {
21324 11 int32_t itemid = current_item_id(itype_magickey);
21325
21326
1/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(itemid<0 ||
21327 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21328 : itemsbuf[itemid].power!=dlevel))
21329 {
21330 11 return game->lvlkeys[dlevel] + game->get_keys() >= num;
21331 }
21332
21333 return true;
21334 11 }
21335
21336 11 bool usekey(int32_t num)
21337 {
21338
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(!canUseKey(num)) return false;
21339
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num; ++q)
21340 {
21341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!usekey()) return false; //should never return false here, but, just to be safe....
21342 8 }
21343 8 return true;
21344 11 }
21345
21346
21347 1262 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
21348 {
21349 1262 int32_t mc = (y&0xF0)+(x>>4);
21350
4/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1176 times.
✓ Branch 5 taken 86 times.
2524 bool ret = (((mc==7||mc==8||mc==23||mc==24) && origin_scr->door[up]==lock)
21351
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1262 times.
✗ Branch 7 not taken.
1262 || ((mc==151||mc==152||mc==167||mc==168) && origin_scr->door[down]==lock)
21352
3/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
1262 || ((mc==64||mc==65||mc==80||mc==81) && origin_scr->door[left]==lock)
21353
5/8
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1253 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1253 times.
1262 || ((mc==78||mc==79||mc==94||mc==95) && origin_scr->door[right]==lock));
21354 1262 return ret;
21355 }
21356
21357 13715869 void HeroClass::oldchecklockblock()
21358 {
21359
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13701514 times.
13715869 if(toogam) return;
21360
21361 13701514 int32_t bx = TRUNCATE_TILE(x.getInt());
21362 13701514 int32_t bx2 = TRUNCATE_TILE(x.getInt() + 8);
21363 13701514 int32_t by = TRUNCATE_TILE(y.getInt());
21364
21365
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3380863 times.
✓ Branch 2 taken 2711494 times.
✓ Branch 3 taken 3671104 times.
✓ Branch 4 taken 3938053 times.
13701514 switch(dir)
21366 {
21367 case up:
21368
4/4
✓ Branch 0 taken 588263 times.
✓ Branch 1 taken 2792600 times.
✓ Branch 2 taken 11867 times.
✓ Branch 3 taken 576396 times.
3380863 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21369
21370 3380863 break;
21371
21372 case down:
21373 2711494 by+=16;
21374 2711494 break;
21375
21376 case left:
21377
2/2
✓ Branch 0 taken 1622499 times.
✓ Branch 1 taken 2048605 times.
3671104 if((((int32_t)x)&0x0F)<8)
21378 2048605 bx-=16;
21379
21380
2/2
✓ Branch 0 taken 2252988 times.
✓ Branch 1 taken 1418116 times.
3671104 if(y.getInt()&8)
21381 {
21382 1418116 by+=16;
21383 1418116 }
21384
21385 3671104 bx2=bx;
21386 3671104 break;
21387
21388 case right:
21389 3938053 bx+=16;
21390
21391
2/2
✓ Branch 0 taken 2426950 times.
✓ Branch 1 taken 1511103 times.
3938053 if(y.getInt()&8)
21392 {
21393 1511103 by+=16;
21394 1511103 }
21395
21396 3938053 bx2=bx;
21397 3938053 break;
21398 }
21399
21400 13701514 bool found1=false;
21401 13701514 bool found2=false;
21402 13701514 int32_t foundlayer = -1;
21403 13701514 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21404 13701514 newcombo const& cmb = combobuf[cid1];
21405 13701514 newcombo const& cmb2 = combobuf[cid2];
21406
4/6
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 13699002 times.
✓ Branch 2 taken 2512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2512 times.
13701514 if((cmb.type==cLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, -1)))
21407 {
21408 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21409 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21410
2/2
✓ Branch 0 taken 919 times.
✓ Branch 1 taken 1593 times.
2512 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dLOCKED);
21411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2512 times.
2512 if (!ignore_layer_0)
21412 {
21413 2512 found1=true;
21414 2512 foundlayer = 0;
21415 2512 }
21416 2512 }
21417
4/6
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 13698797 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
13699002 else if (cmb2.type==cLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, -1))
21418 {
21419
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dLOCKED);
21420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if (!ignore_layer_0)
21421 {
21422 205 found2=true;
21423 205 foundlayer = 0;
21424 205 }
21425 205 }
21426
21427
2/2
✓ Branch 0 taken 27403028 times.
✓ Branch 1 taken 13701514 times.
41104542 for (int32_t i = 0; i <= 1; ++i)
21428 {
21429
2/2
✓ Branch 0 taken 26781664 times.
✓ Branch 1 taken 621364 times.
27403028 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21430 {
21431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found1 = false;
21432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,i)) found2 = false;
21433 26781664 }
21434 else
21435 {
21436
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found1 = false;
21437
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,i)) found2 = false;
21438 }
21439 27403028 }
21440
21441
21442 // Layers
21443
4/4
✓ Branch 0 taken 13699002 times.
✓ Branch 1 taken 2512 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 13698797 times.
13701514 if(!(found1 || found2))
21444 {
21445 13698797 foundlayer = -1;
21446
2/2
✓ Branch 0 taken 13698711 times.
✓ Branch 1 taken 27397559 times.
41096270 for(int32_t i=0; i<2; i++)
21447 {
21448 27397559 cid1 = MAPCOMBO2(i, bx, by);
21449 27397559 cid2 = MAPCOMBO2(i, bx2, by);
21450 27397559 newcombo const& cmb = combobuf[cid1];
21451 27397559 newcombo const& cmb2 = combobuf[cid2];
21452
2/2
✓ Branch 0 taken 13698762 times.
✓ Branch 1 taken 13698797 times.
27397559 if (i == 0)
21453 {
21454
2/2
✓ Branch 0 taken 13388194 times.
✓ Branch 1 taken 310603 times.
13698797 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21455 {
21456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13388194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13388194 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1)) continue; //Continue, because It didn't find any on layer 0, and if you're checking
21457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13388194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13388194 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1)) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
21458 13388194 }
21459 else
21460 {
21461
4/4
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 309270 times.
✓ Branch 2 taken 881 times.
✓ Branch 3 taken 452 times.
310603 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1)) continue;
21462
3/4
✓ Branch 0 taken 881 times.
✓ Branch 1 taken 309270 times.
✓ Branch 2 taken 881 times.
✗ Branch 3 not taken.
310151 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1)) continue;
21463 }
21464 13698345 }
21465
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 27397024 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
27397107 if(cmb.type==cLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, i))
21466 {
21467 83 found1=true;
21468 83 foundlayer = i+1;
21469 83 break;
21470 }
21471
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27397021 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
27397024 else if(cmb2.type==cLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, i))
21472 {
21473 3 found2=true;
21474 3 foundlayer = i+1;
21475 3 break;
21476 }
21477 27397021 }
21478 13698797 }
21479
21480
4/4
✓ Branch 0 taken 13698919 times.
✓ Branch 1 taken 2595 times.
✓ Branch 2 taken 13701113 times.
✓ Branch 3 taken 401 times.
13701514 if(!(found1 || found2) || pushing<8)
21481 {
21482 13701113 return;
21483 }
21484
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 51 times.
401 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
21485
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 262 times.
401 if(!try_locked_combo(cmb3))
21486 262 return;
21487
21488
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 12 times.
139 auto rpos_handle = found1 ? get_rpos_handle_for_world_xy(bx, by, 0) : get_rpos_handle_for_world_xy(bx2, by, 0);
21489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(cmb.usrflags&cflag16)
21490 {
21491 setxmapflag(rpos_handle.screen, 1<<cmb.attribytes[5]);
21492 remove_xstatecombos(create_screen_handles(rpos_handle.base_scr()), 1<<cmb.attribytes[5], false);
21493 }
21494 else
21495 {
21496 139 setmapflag(rpos_handle.scr, mLOCKBLOCK);
21497 139 remove_lockblocks(create_screen_handles(rpos_handle.base_scr()));
21498 }
21499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( cmb3.usrflags&cflag3 )
21500 {
21501 if ( (cmb3.attribytes[3]) )
21502 sfx(cmb3.attribytes[3]);
21503 }
21504 139 else sfx(WAV_DOOR);
21505 13715869 }
21506
21507 13715869 void HeroClass::oldcheckbosslockblock()
21508 {
21509
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13701514 times.
13715869 if(toogam) return;
21510
21511 13701514 int32_t bx = TRUNCATE_TILE(x.getInt());
21512 13701514 int32_t bx2 = TRUNCATE_TILE(x.getInt()+8);
21513 13701514 int32_t by = TRUNCATE_TILE(y.getInt());
21514
21515
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3380863 times.
✓ Branch 2 taken 2711494 times.
✓ Branch 3 taken 3671104 times.
✓ Branch 4 taken 3938053 times.
13701514 switch(dir)
21516 {
21517 case up:
21518
4/4
✓ Branch 0 taken 588263 times.
✓ Branch 1 taken 2792600 times.
✓ Branch 2 taken 576396 times.
✓ Branch 3 taken 11867 times.
3380863 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21519
21520 3380863 break;
21521
21522 case down:
21523 2711494 by+=16;
21524 2711494 break;
21525
21526 case left:
21527
2/2
✓ Branch 0 taken 1622499 times.
✓ Branch 1 taken 2048605 times.
3671104 if((((int32_t)x)&0x0F)<8)
21528 2048605 bx-=16;
21529
21530
2/2
✓ Branch 0 taken 2252988 times.
✓ Branch 1 taken 1418116 times.
3671104 if(y.getInt()&8)
21531 {
21532 1418116 by+=16;
21533 1418116 }
21534
21535 3671104 bx2=bx;
21536 3671104 break;
21537
21538 case right:
21539 3938053 bx+=16;
21540
21541
2/2
✓ Branch 0 taken 2426950 times.
✓ Branch 1 taken 1511103 times.
3938053 if(y.getInt()&8)
21542 {
21543 1511103 by+=16;
21544 1511103 }
21545
21546 3938053 bx2=bx;
21547 3938053 break;
21548 }
21549
21550
21551 13701514 bool found1 = false;
21552 13701514 bool found2 = false;
21553 13701514 int32_t foundlayer = -1;
21554 13701514 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21555 13701514 newcombo const& cmb = combobuf[cid1];
21556 13701514 newcombo const& cmb2 = combobuf[cid2];
21557 13701514 int cmb_screen_index = 0;
21558
21559
4/6
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 13700187 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1327 times.
13701514 if((cmb.type==cBOSSLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, -1)))
21560 {
21561 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21562 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21563
2/2
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 321 times.
1327 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dBOSS);
21564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 if (!ignore_layer_0)
21565 {
21566 1327 found1=true;
21567 1327 foundlayer = 0;
21568 1327 cmb_screen_index = get_screen_for_world_xy(bx, by);
21569 1327 }
21570 1327 }
21571
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 13700156 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
13700187 else if (cmb2.type==cBOSSLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, -1))
21572 {
21573
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dBOSS);
21574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (!ignore_layer_0)
21575 {
21576 31 found2=true;
21577 31 foundlayer = 0;
21578 31 cmb_screen_index = get_screen_for_world_xy(bx2, by);
21579 31 }
21580 31 }
21581
21582
2/2
✓ Branch 0 taken 27403028 times.
✓ Branch 1 taken 13701514 times.
41104542 for (int32_t i = 0; i <= 1; ++i)
21583 {
21584
2/2
✓ Branch 0 taken 26781664 times.
✓ Branch 1 taken 621364 times.
27403028 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21585 {
21586
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, i)) found1 = false;
21587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, i)) found2 = false;
21588 26781664 }
21589 else
21590 {
21591
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, i)) found1 = false;
21592
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, i)) found2 = false;
21593 }
21594 27403028 }
21595
21596
21597 // Layers
21598
4/4
✓ Branch 0 taken 13700187 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 13700156 times.
13701514 if (!(found1 || found2))
21599 {
21600 13700156 foundlayer = -1;
21601
2/2
✓ Branch 0 taken 13700156 times.
✓ Branch 1 taken 27400312 times.
41100468 for (int32_t i = 0; i < 2; i++)
21602 {
21603 27400312 cid1 = MAPCOMBO2(i, bx, by);
21604 27400312 cid2 = MAPCOMBO2(i, bx2, by);
21605 27400312 newcombo const& cmb = combobuf[cid1];
21606 27400312 newcombo const& cmb2 = combobuf[cid2];
21607
2/2
✓ Branch 0 taken 13700156 times.
✓ Branch 1 taken 13700156 times.
27400312 if (i == 0)
21608 {
21609
2/2
✓ Branch 0 taken 11798354 times.
✓ Branch 1 taken 1901802 times.
13700156 if (get_scr_layer_valid(hero_screen, 2))
21610 {
21611
2/2
✓ Branch 0 taken 1767354 times.
✓ Branch 1 taken 134448 times.
1901802 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21612 {
21613
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767354 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by)) continue;
21614
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767354 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by)) continue;
21615 1767354 }
21616 else
21617 {
21618
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 133996 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
134448 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by)) continue;
21619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133996 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133996 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by)) continue;
21620 }
21621 1901350 }
21622 13699704 }
21623
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27399860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27399860 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx, by, 1, i))
21624 {
21625 found1 = true;
21626 foundlayer = i;
21627 cmb_screen_index = get_screen_for_world_xy(bx, by);
21628 break;
21629 }
21630
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27399860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27399860 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2, by, 1, i))
21631 {
21632 found2 = true;
21633 foundlayer = i;
21634 cmb_screen_index = get_screen_for_world_xy(bx2, by);
21635 break;
21636 }
21637 27399860 }
21638 13700156 }
21639
21640
4/4
✓ Branch 0 taken 13700187 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 13701043 times.
✓ Branch 3 taken 471 times.
13701514 if (!(found1 || found2) || pushing < 8)
21641 {
21642 13701043 return;
21643 }
21644
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 3 times.
471 int32_t cid = found1 ? cid1 : cid2;
21645
21646
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 436 times.
471 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21647
21648
21649 // Run Boss Key Script
21650 35 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380 times.
2380 for ( int32_t q = 0; q < MAXITEMS; ++q )
21652 {
21653
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 35 times.
2380 if ( itemsbuf[q].family == itype_bosskey )
21654 {
21655 35 key_item = q; break;
21656 }
21657 2345 }
21658
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21659 {
21660 int i = key_item;
21661 FFCore.reset_script_engine_data(ScriptType::Item, i);
21662 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21663 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21664 }
21665
21666 35 mapscr* scr = get_scr(cmb_screen_index);
21667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag16)
21668 {
21669 setxmapflag(cmb_screen_index, 1<<cmb.attribytes[5]);
21670 remove_xstatecombos(create_screen_handles(scr), 1<<cmb.attribytes[5]);
21671 }
21672 else
21673 {
21674 35 setmapflag(scr, mBOSSLOCKBLOCK);
21675 35 remove_bosslockblocks(create_screen_handles(scr));
21676 }
21677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (combobuf[cid].attribytes[3]) )
21678 35 sfx(combobuf[cid].attribytes[3]);
21679 13715869 }
21680
21681 39689814 void HeroClass::oldcheckchest(int32_t type)
21682 {
21683 // chests aren't affected by hero_scr->flags2&fAIRCOMBOS
21684
5/6
✓ Branch 0 taken 39649596 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 39608847 times.
✓ Branch 3 taken 40749 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39608847 times.
39689814 if(toogam || z>0 || fakez > 0) return;
21685
2/2
✓ Branch 0 taken 37981761 times.
✓ Branch 1 taken 1627086 times.
39608847 if(pushing<8) return;
21686
21687 1627086 int32_t bx = TRUNCATE_TILE(x.getInt());
21688 1627086 int32_t bx2 = TRUNCATE_TILE(x.getInt()+8);
21689 1627086 int32_t by = TRUNCATE_TILE(y.getInt());
21690
21691
3/4
✓ Branch 0 taken 872424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 347538 times.
✓ Branch 3 taken 407124 times.
1627086 switch(dir)
21692 {
21693 case up:
21694
2/2
✓ Branch 0 taken 52566 times.
✓ Branch 1 taken 354558 times.
407124 if(isSideViewHero()) return;
21695
21696
4/4
✓ Branch 0 taken 81006 times.
✓ Branch 1 taken 273552 times.
✓ Branch 2 taken 78609 times.
✓ Branch 3 taken 2397 times.
354558 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21697
21698 354558 break;
21699
21700 case left:
21701 case right:
21702
2/2
✓ Branch 0 taken 19974 times.
✓ Branch 1 taken 852450 times.
872424 if(isSideViewHero()) break;
21703 [[fallthrough]];
21704 case down:
21705 1199988 return;
21706 }
21707
21708 374532 bool found=false;
21709 374532 int found_screen_index=0;
21710 374532 bool itemflag=false;
21711
21712
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 374395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
374532 if (combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))
21713 {
21714 137 found=true;
21715 137 found_screen_index=get_screen_for_world_xy(bx, by);
21716 137 }
21717
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 374360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
374395 else if (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1))
21718 {
21719 35 found=true;
21720 35 found_screen_index=get_screen_for_world_xy(bx2, by);
21721 35 }
21722
2/2
✓ Branch 0 taken 749064 times.
✓ Branch 1 taken 374532 times.
1123596 for (int32_t i = 0; i <= 1; ++i)
21723 {
21724
2/2
✓ Branch 0 taken 747864 times.
✓ Branch 1 taken 1200 times.
749064 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21725 {
21726
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 747864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
747864 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found = false;
21727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 747864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
747864 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,i)) found = false;
21728 747864 }
21729 else
21730 {
21731
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1200 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found = false;
21732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1200 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,i)) found = false;
21733 }
21734 749064 }
21735
21736
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 374360 times.
374532 if(!found)
21737 {
21738
2/2
✓ Branch 0 taken 374360 times.
✓ Branch 1 taken 748720 times.
1123080 for(int32_t i=0; i<2; i++)
21739 {
21740
2/2
✓ Branch 0 taken 374360 times.
✓ Branch 1 taken 374360 times.
748720 if (i == 0)
21741 {
21742
2/2
✓ Branch 0 taken 373760 times.
✓ Branch 1 taken 600 times.
374360 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21743 {
21744
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 373760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
373760 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) continue;
21745
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 373760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
373760 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1)) continue;
21746 373760 }
21747 else
21748 {
21749
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) continue;
21750
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1)) continue;
21751 }
21752 374360 }
21753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
748720 if (combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))
21754 {
21755 found=true;
21756 found_screen_index=get_screen_for_world_xy(bx, by);
21757 break;
21758 }
21759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
748720 else if (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i))
21760 {
21761 found=true;
21762 found_screen_index=get_screen_for_world_xy(bx2, by);
21763 break;
21764 }
21765 748720 }
21766 374360 }
21767
21768
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 374360 times.
374532 if(!found)
21769 {
21770 374360 return;
21771 }
21772
21773 172 mapscr* scr = get_scr(found_screen_index);
21774
21775
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 2 times.
172 switch(type)
21776 {
21777 case cLOCKEDCHEST:
21778
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 56 times.
69 if(!usekey()) return;
21779
21780 13 setmapflag(scr, mLOCKEDCHEST);
21781 13 break;
21782
21783 case cCHEST:
21784 101 setmapflag(scr, mCHEST);
21785 101 break;
21786
21787 case cBOSSCHEST:
21788
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
21789 // Run Boss Key Script
21790 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
21792 {
21793
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].family == itype_bosskey )
21794 {
21795 2 key_item = q; break;
21796 }
21797 134 }
21798
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21799 {
21800 int i = key_item;
21801 FFCore.reset_script_engine_data(ScriptType::Item, i);
21802 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21803 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21804 }
21805 2 setmapflag(scr, mBOSSCHEST);
21806 2 break;
21807 }
21808
21809 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21810 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21811 116 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
21812 116 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
21813 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
21814 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
21815
21816
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!itemflag)
21817 {
21818 for(int32_t i=0; i<2; i++)
21819 {
21820 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
21821 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
21822 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
21823 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
21824 }
21825 }
21826
21827
3/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 if(itemflag && !getmapflag(found_screen_index, (found_screen_index < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
21828 {
21829
4/8
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 add_item_for_screen(found_screen_index, new item(x, y,(zfix)0, scr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
21830 116 }
21831 39689814 }
21832
21833 4294064 void HeroClass::checkchest(int32_t type)
21834 {
21835
4/4
✓ Branch 0 taken 3240886 times.
✓ Branch 1 taken 1053178 times.
✓ Branch 2 taken 1053178 times.
✓ Branch 3 taken 2187708 times.
4294064 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
21836
2/2
✓ Branch 0 taken 567265 times.
✓ Branch 1 taken 3726799 times.
4294064 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
21837
2/2
✓ Branch 0 taken 567265 times.
✓ Branch 1 taken 3726799 times.
4294064 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
21838
2/2
✓ Branch 0 taken 567265 times.
✓ Branch 1 taken 3726799 times.
4294064 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
21839
2/2
✓ Branch 0 taken 1134530 times.
✓ Branch 1 taken 3159534 times.
4294064 if(ischest)
21840 {
21841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3159534 times.
3159534 if(get_qr(qr_OLD_CHEST_COLLISION))
21842 {
21843 oldcheckchest(type);
21844 return;
21845 }
21846 3159534 }
21847
3/4
✓ Branch 0 taken 1134530 times.
✓ Branch 1 taken 3159534 times.
✓ Branch 2 taken 1134530 times.
✗ Branch 3 not taken.
4294064 if(islockblock && get_qr(qr_OLD_LOCKBLOCK_COLLISION))
21848 {
21849 if(type == cLOCKBLOCK)
21850 oldchecklockblock();
21851 else if(type == cBOSSLOCKBLOCK)
21852 oldcheckbosslockblock();
21853 return;
21854 }
21855
5/6
✓ Branch 0 taken 4288227 times.
✓ Branch 1 taken 5837 times.
✓ Branch 2 taken 4264311 times.
✓ Branch 3 taken 23916 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4264311 times.
4294064 if(toogam || z>0 || fakez > 0) return;
21856 4264311 zfix bx, by;
21857 4264311 zfix bx2, by2;
21858 4264311 zfix fx(-1), fy(-1);
21859
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 921679 times.
✓ Branch 2 taken 953160 times.
✓ Branch 3 taken 1168231 times.
✓ Branch 4 taken 1221241 times.
4264311 switch(dir)
21860 {
21861 case up:
21862 921679 by = y + (bigHitbox ? -2 : 6);
21863 921679 by2 = by;
21864 921679 bx = x + 4;
21865 921679 bx2 = bx + 8;
21866 921679 break;
21867 case down:
21868 953160 by = y + 17;
21869 953160 by2 = by;
21870 953160 bx = x + 4;
21871 953160 bx2 = bx + 8;
21872 953160 break;
21873 case left:
21874 1168231 by = y + (bigHitbox ? 0 : 8);
21875 1168231 by2 = y + 8;
21876 1168231 bx = x - 2;
21877 1168231 bx2 = x - 2;
21878 1168231 break;
21879 case right:
21880 1221241 by = y + (bigHitbox ? 0 : 8);
21881 1221241 by2 = y + 8;
21882 1221241 bx = x + 17;
21883 1221241 bx2 = x + 17;
21884 1221241 break;
21885 }
21886
21887 4264311 int32_t found = -1;
21888 4264311 int32_t foundlayer = 0;
21889
21890 4264311 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
21891
21892
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 4261591 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
4264311 if(cmb->type==type && !(cmb->only_gentrig) && _effectflag(bx,by,1, -1))
21893 {
21894 2720 found = MAPCOMBO(bx,by);
21895 2720 fx = bx; fy = by;
21896
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 2720 times.
8160 for (int32_t i = 0; i <= 1; ++i)
21897 {
21898
2/2
✓ Branch 0 taken 3484 times.
✓ Branch 1 taken 1956 times.
5440 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21899 {
21900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3484 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) found = -1;
21901 3484 }
21902 else
21903 {
21904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1956 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) found = -1;
21905 }
21906 5440 }
21907 2720 }
21908
2/2
✓ Branch 0 taken 4261591 times.
✓ Branch 1 taken 2720 times.
4264311 if(found<0)
21909 {
21910 4261591 cmb = &combobuf[MAPCOMBO(bx2,by2)];
21911
4/6
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4261507 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
4261591 if(cmb->type==type && !(cmb->only_gentrig) && _effectflag(bx2,by2,1, -1))
21912 {
21913 84 found = MAPCOMBO(bx2,by2);
21914
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 504 times.
588 for (int32_t i = 0; i < 6; ++i)
21915 {
21916
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 228 times.
504 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21917 {
21918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,i))
21919 {
21920 found = -1;
21921 break;
21922 }
21923 276 }
21924 else
21925 {
21926
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
228 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,i))
21927 {
21928 found = -1;
21929 break;
21930 }
21931 }
21932 504 }
21933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(found != -1)
21934 {
21935 84 fx = bx2; fy = by2;
21936 84 }
21937 84 }
21938 4261591 }
21939
21940
2/2
✓ Branch 0 taken 4261507 times.
✓ Branch 1 taken 2804 times.
4264311 if(found<0)
21941 {
21942
2/2
✓ Branch 0 taken 4261266 times.
✓ Branch 1 taken 25567933 times.
29829199 for(int32_t i=0; i<6; i++)
21943 {
21944 25567933 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
21945
4/6
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 25567706 times.
✓ Branch 2 taken 227 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 227 times.
25567933 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->only_gentrig) && _effectflag(bx,by,1, i))
21946 {
21947 227 found = MAPCOMBO2(i,bx,by);
21948
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 1069 times.
1296 for(int32_t j = i+1; j < 6; ++j)
21949 {
21950
2/2
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 539 times.
1069 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21951 {
21952
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 530 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
530 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,j))
21953 {
21954 found = -1;
21955 break;
21956 }
21957 530 }
21958 else
21959 {
21960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
539 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,j))
21961 {
21962 found = -1;
21963 break;
21964 }
21965 }
21966 1069 }
21967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(found>-1)
21968 {
21969 227 foundlayer = i+1;
21970 227 fx = bx; fy = by;
21971 227 break;
21972 }
21973 }
21974 25567706 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
21975
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 25567692 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
25567706 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->only_gentrig) && _effectflag(bx2,by2,1, i))
21976 {
21977 14 found = MAPCOMBO2(i,bx2,by2);
21978
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 40 times.
54 for(int32_t j = i+1; j < 6; ++j)
21979 {
21980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21981 {
21982 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,j))
21983 {
21984 found = -1;
21985 break;
21986 }
21987 }
21988 else
21989 {
21990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,j))
21991 {
21992 found = -1;
21993 break;
21994 }
21995 }
21996 40 }
21997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(found>-1)
21998 {
21999 14 foundlayer = i+1;
22000 14 fx = bx2; fy = by2;
22001 14 break;
22002 }
22003 }
22004 25567692 }
22005 4261507 }
22006
22007
2/2
✓ Branch 0 taken 4261266 times.
✓ Branch 1 taken 3045 times.
4264311 if(found<0) return;
22008 3045 cmb = &combobuf[found];
22009
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2819 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 78 times.
3045 switch(dir)
22010 {
22011 case up:
22012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2819 times.
2819 if(cmb->usrflags&cflag10)
22013 return;
22014 2819 break;
22015 case down:
22016
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 57 times.
126 if(cmb->usrflags&cflag9)
22017 69 return;
22018 57 break;
22019 case left:
22020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(cmb->usrflags&cflag12)
22021 return;
22022 22 break;
22023 case right:
22024
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 17 times.
78 if(cmb->usrflags&cflag11)
22025 61 return;
22026 17 break;
22027 }
22028 2915 int32_t intbtn = cmb->attribytes[2];
22029
22030
2/2
✓ Branch 0 taken 2786 times.
✓ Branch 1 taken 129 times.
2915 if(intbtn) //
22031 {
22032
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 2700 times.
2786 if(cmb->usrflags & cflag13) //display prompt
22033 {
22034 2700 int altcmb = cmb->attributes[2]/10000;
22035 2700 prompt_combo = cmb->attributes[1]/10000;
22036
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2700 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2700 if(altcmb && ((islocked && !can_locked_combo(*cmb))
22037 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
22038 prompt_combo = altcmb;
22039 2700 prompt_cset = cmb->attribytes[4];
22040 2700 prompt_x = cmb->attrishorts[0];
22041 2700 prompt_y = cmb->attrishorts[1];
22042 2700 }
22043
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 2720 times.
2786 if(!getIntBtnInput(intbtn, true, true, false, false))
22044 {
22045 2720 return; //Button not pressed
22046 }
22047 66 }
22048
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
129 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
22049
22050
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 21 times.
75 if(ischest)
22051 {
22052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if (!trigger_chest(get_rpos_handle_for_world_xy(fx, fy, foundlayer))) return;
22053 54 }
22054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(islockblock)
22055 {
22056
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
21 if (!trigger_lockblock(get_rpos_handle_for_world_xy(fx, fy, foundlayer))) return;
22057 18 }
22058
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 59 times.
72 if(intbtn && (cmb->usrflags & cflag13))
22059 59 prompt_combo = 0;
22060 4294064 }
22061
22062 16852210 void HeroClass::checkgenpush(rpos_t rpos)
22063 {
22064
2/2
✓ Branch 0 taken 16815899 times.
✓ Branch 1 taken 36311 times.
16852210 if (rpos == rpos_t::None)
22065 36311 return;
22066
22067
2/2
✓ Branch 0 taken 16815899 times.
✓ Branch 1 taken 117711293 times.
134527192 for (int layer = 0; layer < 7; ++layer)
22068 {
22069 117711293 auto rpos_handle = get_rpos_handle(rpos, layer);
22070
1/2
✓ Branch 0 taken 117711293 times.
✗ Branch 1 not taken.
121020400 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
22071
2/2
✓ Branch 0 taken 3307497 times.
✓ Branch 1 taken 1610 times.
3309107 if(!trig.trigger_flags.get(TRIGFLAG_PUSH)) return false;
22072
3/4
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
1610 return pushing && !(pushing % zc_max(1,trig.trig_pushtime));
22073 3309107 });
22074 117711293 }
22075 16852210 }
22076
22077 14309406 void HeroClass::checkgenpush()
22078 {
22079 14309406 zfix bx, by;
22080 14309406 zfix bx2, by2;
22081
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3505152 times.
✓ Branch 2 taken 2840833 times.
✓ Branch 3 taken 3835605 times.
✓ Branch 4 taken 4127816 times.
14309406 switch(dir)
22082 {
22083 case up:
22084 3505152 by = y + (bigHitbox ? -2 : 6);
22085 3505152 by2 = by;
22086 3505152 bx = x + 4;
22087 3505152 bx2 = bx + 8;
22088 3505152 break;
22089 case down:
22090 2840833 by = y + 17;
22091 2840833 by2 = by;
22092 2840833 bx = x + 4;
22093 2840833 bx2 = bx + 8;
22094 2840833 break;
22095 case left:
22096 3835605 by = y + (bigHitbox ? 0 : 8);
22097 3835605 by2 = y + 8;
22098 3835605 bx = x - 2;
22099 3835605 bx2 = x - 2;
22100 3835605 break;
22101 case right:
22102 4127816 by = y + (bigHitbox ? 0 : 8);
22103 4127816 by2 = y + 8;
22104 4127816 bx = x + 17;
22105 4127816 bx2 = x + 17;
22106 4127816 break;
22107 }
22108
22109 14309406 rpos_t rpos_1 = COMBOPOS_REGION_B(bx, by);
22110 14309406 rpos_t rpos_2 = COMBOPOS_REGION_B(bx2, by2);
22111 14309406 checkgenpush(rpos_1);
22112
2/2
✓ Branch 0 taken 11766602 times.
✓ Branch 1 taken 2542804 times.
14309406 if (rpos_1 != rpos_2) checkgenpush(rpos_2);
22113
22114
2/2
✓ Branch 0 taken 13302149 times.
✓ Branch 1 taken 1007257 times.
14309406 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22115 {
22116 3553157 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
22117
4/4
✓ Branch 0 taken 2514429 times.
✓ Branch 1 taken 31471 times.
✓ Branch 2 taken 1278 times.
✓ Branch 3 taken 2513151 times.
2545900 if (ffcIsAt(ffc_handle, bx, by) || ffcIsAt(ffc_handle, bx2, by2))
22118 {
22119
1/2
✓ Branch 0 taken 32749 times.
✗ Branch 1 not taken.
33378 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
22120
1/2
✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
629 if(!trig.trigger_flags.get(TRIGFLAG_PUSH)) return false;
22121 return pushing && !(pushing % zc_max(1,trig.trig_pushtime));
22122 629 });
22123 32749 }
22124 2545900 return true;
22125 });
22126 1007257 }
22127 14309406 }
22128
22129 14309408 void HeroClass::checksigns() //Also checks for generic trigger buttons
22130 {
22131
5/6
✓ Branch 0 taken 14294455 times.
✓ Branch 1 taken 14953 times.
✓ Branch 2 taken 14275332 times.
✓ Branch 3 taken 19123 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14275332 times.
14309408 if(toogam || z>0 || fakez>0) return;
22132
5/6
✓ Branch 0 taken 14159350 times.
✓ Branch 1 taken 115982 times.
✓ Branch 2 taken 240882 times.
✓ Branch 3 taken 13918468 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 240882 times.
14275332 if(msg_active || (msg_onscreen && get_qr(qr_MSGDISAPPEAR)))
22133 115982 return; //Don't overwrite a message waiting to be dismissed
22134 14159350 zfix bx, by;
22135 14159350 zfix bx2, by2;
22136 14159350 zfix fx(-1), fy(-1);
22137
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3407028 times.
✓ Branch 2 taken 2829422 times.
✓ Branch 3 taken 3819617 times.
✓ Branch 4 taken 4103283 times.
14159350 switch(dir)
22138 {
22139 case up:
22140 3407028 by = y + (bigHitbox ? -2 : 6);
22141 3407028 by2 = by;
22142 3407028 bx = x + 4;
22143 3407028 bx2 = bx + 8;
22144 3407028 break;
22145 case down:
22146 2829422 by = y + 17;
22147 2829422 by2 = by;
22148 2829422 bx = x + 4;
22149 2829422 bx2 = bx + 8;
22150 2829422 break;
22151 case left:
22152 3819617 by = y + (bigHitbox ? 0 : 8);
22153 3819617 by2 = y + 8;
22154 3819617 bx = x - 2;
22155 3819617 bx2 = x - 2;
22156 3819617 break;
22157 case right:
22158 4103283 by = y + (bigHitbox ? 0 : 8);
22159 4103283 by2 = y + 8;
22160 4103283 bx = x + 17;
22161 4103283 bx2 = x + 17;
22162 4103283 break;
22163 }
22164
22165 14159350 int32_t found = -1;
22166 14159350 int32_t found_screen = -1;
22167 14159350 std::optional<ffc_handle_t> foundffc;
22168 14159350 int32_t found_lyr = 0;
22169 14159350 bool found_sign = false;
22170 14159350 int32_t tmp_cid = MAPCOMBO(bx, by);
22171 14159350 int32_t screen = get_screen_for_world_xy(bx, by);
22172 14159350 newcombo const* tmp_cmb = &combobuf[tmp_cid];
22173 14159350 bool has_trigger_button = false;
22174
2/2
✓ Branch 0 taken 14153614 times.
✓ Branch 1 taken 395662 times.
14549276 for(auto& trig : tmp_cmb->triggers)
22175
2/2
✓ Branch 0 taken 389926 times.
✓ Branch 1 taken 5736 times.
395662 if(trig.triggerbtn)
22176 {
22177 5736 has_trigger_button = true;
22178 5736 break;
22179 }
22180
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14159328 times.
14165108 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22181
2/2
✓ Branch 0 taken 5758 times.
✓ Branch 1 taken 14153592 times.
14159350 || has_trigger_button) && _effectflag(bx,by,1, -1))
22182 {
22183 5758 found = tmp_cid;
22184 5758 found_screen = screen;
22185 5758 fx = bx; fy = by;
22186
2/2
✓ Branch 0 taken 11516 times.
✓ Branch 1 taken 5758 times.
17274 for (int32_t i = 0; i <= 1; ++i)
22187 {
22188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11516 times.
11516 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22189 {
22190 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found = -1;
22191 }
22192 else
22193 {
22194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11516 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found = -1;
22195 }
22196 11516 }
22197 5758 }
22198 14159350 tmp_cid = MAPCOMBO(bx2,by2);
22199 14159350 screen = get_screen_for_world_xy(bx2, by2);
22200 14159350 tmp_cmb = &combobuf[tmp_cid];
22201 14159350 has_trigger_button = false;
22202
2/2
✓ Branch 0 taken 14153130 times.
✓ Branch 1 taken 396800 times.
14549930 for(auto& trig : tmp_cmb->triggers)
22203
2/2
✓ Branch 0 taken 390580 times.
✓ Branch 1 taken 6220 times.
396800 if(trig.triggerbtn)
22204 {
22205 6220 has_trigger_button = true;
22206 6220 break;
22207 }
22208
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14159328 times.
14165592 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22209
2/2
✓ Branch 0 taken 6242 times.
✓ Branch 1 taken 14153108 times.
14159350 || has_trigger_button) && _effectflag(bx2,by2,1, -1))
22210 {
22211 6242 found = tmp_cid;
22212 6242 found_screen = screen;
22213 6242 fx = bx2; fy = by2;
22214
2/2
✓ Branch 0 taken 12484 times.
✓ Branch 1 taken 6242 times.
18726 for (int32_t i = 0; i <= 1; ++i)
22215 {
22216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12484 times.
12484 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22217 {
22218 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,i)) found = -1;
22219 }
22220 else
22221 {
22222
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12484 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,i)) found = -1;
22223 }
22224 12484 }
22225 6242 }
22226
22227
2/2
✓ Branch 0 taken 13159200 times.
✓ Branch 1 taken 1000150 times.
14159350 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22228 {
22229 3279165 foundffc = find_ffc([&](const ffc_handle_t& ffc_handle) {
22230
4/4
✓ Branch 0 taken 2247789 times.
✓ Branch 1 taken 31226 times.
✓ Branch 2 taken 1278 times.
✓ Branch 3 taken 2246511 times.
2279015 if (ffcIsAt(ffc_handle, bx, by) || ffcIsAt(ffc_handle, bx2, by2))
22231 {
22232 32504 tmp_cmb = &ffc_handle.combo();
22233 32504 has_trigger_button = false;
22234
2/2
✓ Branch 0 taken 32504 times.
✓ Branch 1 taken 629 times.
33133 for(auto& trig : tmp_cmb->triggers)
22235
1/2
✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
629 if(trig.triggerbtn)
22236 {
22237 has_trigger_button = true;
22238 break;
22239 }
22240
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32504 times.
32504 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22241 32504 || has_trigger_button) && true) //!TODO: FFC effect flag?
22242 {
22243 return true;
22244 }
22245 32504 }
22246
22247 2279015 return false;
22248 2279015 });
22249 1000150 }
22250
22251
3/4
✓ Branch 0 taken 14152927 times.
✓ Branch 1 taken 6423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14152927 times.
14159350 if(found<0 && !foundffc)
22252 {
22253 14152927 screen = get_screen_for_world_xy(bx, by);
22254
2/2
✓ Branch 0 taken 14150831 times.
✓ Branch 1 taken 84907781 times.
99058612 for(int32_t i=0; i<6; i++)
22255 {
22256 84907781 tmp_cid = MAPCOMBO2(i,bx,by);
22257 84907781 tmp_cmb = &combobuf[tmp_cid];
22258 84907781 has_trigger_button = false;
22259
2/2
✓ Branch 0 taken 84906432 times.
✓ Branch 1 taken 2473905 times.
87380337 for(auto& trig : tmp_cmb->triggers)
22260
2/2
✓ Branch 0 taken 2472556 times.
✓ Branch 1 taken 1349 times.
2473905 if(trig.triggerbtn)
22261 {
22262 1349 has_trigger_button = true;
22263 1349 break;
22264 }
22265
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 84907087 times.
84909824 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22266
2/2
✓ Branch 0 taken 2043 times.
✓ Branch 1 taken 84905738 times.
84907781 || has_trigger_button) && _effectflag(bx,by,1, i))
22267 {
22268 2043 found = tmp_cid;
22269 2043 found_screen = screen;
22270 2043 found_lyr = i+1;
22271 2043 fx = bx; fy = by;
22272
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 1382 times.
2043 if (i == 0)
22273 {
22274
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 238 times.
1382 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22275 {
22276
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1144 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) found = -1;
22277 1144 }
22278 else
22279 {
22280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 238 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
238 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) found = -1;
22281 }
22282 1382 }
22283 2043 }
22284 84907781 screen = get_screen_for_world_xy(bx2, by2);
22285 84907781 tmp_cid = MAPCOMBO2(i,bx2,by2);
22286 84907781 tmp_cmb = &combobuf[tmp_cid];
22287 84907781 has_trigger_button = false;
22288
2/2
✓ Branch 0 taken 84906531 times.
✓ Branch 1 taken 2471839 times.
87378370 for(auto& trig : tmp_cmb->triggers)
22289
2/2
✓ Branch 0 taken 2470589 times.
✓ Branch 1 taken 1250 times.
2471839 if(trig.triggerbtn)
22290 {
22291 1250 has_trigger_button = true;
22292 1250 break;
22293 }
22294
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 84907095 times.
84909717 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22295
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 84905845 times.
84907781 || has_trigger_button) && _effectflag(bx2,by2,1, i))
22296 {
22297 1936 found = tmp_cid;
22298 1936 found_screen = screen;
22299 1936 found_lyr = i+1;
22300 1936 fx = bx2; fy = by2;
22301
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 1283 times.
1936 if (i == 0)
22302 {
22303
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 251 times.
1283 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22304 {
22305
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1032 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1)) found = -1;
22306 1032 }
22307 else
22308 {
22309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
251 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1)) found = -1;
22310 }
22311 1283 }
22312 1936 }
22313
2/2
✓ Branch 0 taken 84905685 times.
✓ Branch 1 taken 2096 times.
84907781 if(found>-1) break;
22314 84905685 }
22315 14152927 }
22316
22317
3/4
✓ Branch 0 taken 14150831 times.
✓ Branch 1 taken 8519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14150831 times.
14159350 if(found<0&&!foundffc) return;
22318
22319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
8519 newcombo const& cmb = combobuf[foundffc ? foundffc->data() : found];
22320
22321 8519 byte signInput = 0;
22322 8519 bool didsign = false, didprompt = false;
22323
3/4
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 7765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
8540 if(cmb.type == cSIGNPOST && !(cmb.only_gentrig))
22324 {
22325
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 35 times.
754 switch(dir)
22326 {
22327 case up:
22328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
599 if(cmb.usrflags&cflag10)
22329 goto endsigns;
22330 599 break;
22331 case down:
22332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(cmb.usrflags&cflag9)
22333 goto endsigns;
22334 116 break;
22335 case left:
22336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb.usrflags&cflag12)
22337 goto endsigns;
22338 4 break;
22339 case right:
22340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag11)
22341 goto endsigns;
22342 35 break;
22343 }
22344 754 int32_t intbtn = cmb.attribytes[2];
22345
22346
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(intbtn) //
22347 {
22348 754 signInput = getIntBtnInput(intbtn, true, true, false, false);
22349
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 733 times.
754 if(!signInput)
22350 {
22351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
733 if(cmb.usrflags & cflag13) //display prompt
22352 {
22353 733 prompt_combo = cmb.attributes[1]/10000;
22354 733 prompt_cset = cmb.attribytes[4];
22355 733 prompt_x = cmb.attrishorts[0];
22356 733 prompt_y = cmb.attrishorts[1];
22357 733 didprompt = true;
22358 733 }
22359 733 goto endsigns; //Button not pressed
22360 }
22361 21 }
22362 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
22363
22364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 trigger_sign(cmb, foundffc ? foundffc->screen : found_screen);
22365 21 didsign = true;
22366 21 }
22367 endsigns:
22368 8519 auto& cpos = cpos_get(get_rpos_handle_for_world_xy(fx, fy, found_lyr));
22369 int dir_trigflag;
22370
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✓ Branch 2 taken 6674 times.
✓ Branch 3 taken 802 times.
✓ Branch 4 taken 520 times.
8519 switch(dir)
22371 {
22372 case down:
22373 523 dir_trigflag = TRIGFLAG_BTN_TOP;
22374 523 break;
22375 case up:
22376 6674 dir_trigflag = TRIGFLAG_BTN_BOTTOM;
22377 6674 break;
22378 case right:
22379 802 dir_trigflag = TRIGFLAG_BTN_LEFT;
22380 802 break;
22381 case left:
22382 520 dir_trigflag = TRIGFLAG_BTN_RIGHT;
22383 520 break;
22384 }
22385 8519 bool found_a_trigger_dir = false, did_trigger = false;
22386 8519 combined_handle_t comb_handle;
22387
2/4
✓ Branch 0 taken 8519 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8519 times.
8519 if(fx != -1 && fy != -1)
22388 8519 comb_handle = get_rpos_handle_for_world_xy(fx, fy, found_lyr);
22389
1/2
✓ Branch 0 taken 8519 times.
✗ Branch 1 not taken.
8519 if(foundffc)
22390 comb_handle = foundffc.value();
22391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
16284 did_trigger = trig_each_combo_trigger(comb_handle, [&](combo_trigger const& trig, size_t idx){
22392
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7690 times.
7765 if(!trig.trigger_flags.get(dir_trigflag)) return false;
22393 7690 found_a_trigger_dir = true;
22394 7690 auto& trig_data = cpos.trig_data[idx];
22395
3/6
✓ Branch 0 taken 7690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7690 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7690 times.
7690 if(fx != -1 && fy != -1 && trig_data.cooldown) return false;
22396
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7690 times.
✓ Branch 2 taken 7513 times.
✓ Branch 3 taken 177 times.
15380 return trig.triggerbtn && (getIntBtnInput(trig.triggerbtn, true, true, false, false) || checkIntBtnVal(trig.triggerbtn, signInput));
22397 7765 });
22398
5/6
✓ Branch 0 taken 7688 times.
✓ Branch 1 taken 831 times.
✓ Branch 2 taken 7688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175 times.
✓ Branch 5 taken 7513 times.
8519 if(!found_a_trigger_dir || didprompt || did_trigger)
22399 1006 return;
22400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7513 times.
7513 else if(cmb.type == cBUTTONPROMPT)
22401 {
22402 prompt_combo = cmb.attributes[0]/10000;
22403 prompt_cset = cmb.attribytes[0];
22404 prompt_x = cmb.attrishorts[0];
22405 prompt_y = cmb.attrishorts[1];
22406 }
22407
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 7513 times.
8875 else for (size_t idx = 0; idx < cmb.triggers.size(); ++idx)
22408 {
22409 7513 auto& trig_data = cpos.trig_data[idx];
22410
3/6
✓ Branch 0 taken 7513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7513 times.
✗ Branch 5 not taken.
7513 if(fx != -1 && fy != -1 && trig_data.cooldown) continue;
22411 7513 auto& trig = cmb.triggers[idx];
22412 7513 bool cond = check_trig_conditions(comb_handle, idx);
22413
2/2
✓ Branch 0 taken 7333 times.
✓ Branch 1 taken 180 times.
7513 auto pcid = cond ? trig.prompt_cid : trig.fail_prompt_cid;
22414
2/2
✓ Branch 0 taken 7333 times.
✓ Branch 1 taken 180 times.
7513 auto pcs = cond ? trig.prompt_cs : trig.fail_prompt_cs;
22415
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 6151 times.
7513 if(pcid)
22416 {
22417 6151 prompt_combo = pcid;
22418 6151 prompt_cset = pcs;
22419 6151 prompt_x = trig.prompt_x;
22420 6151 prompt_y = trig.prompt_y;
22421 6151 break;
22422 }
22423 1362 }
22424 14309408 }
22425
22426 // Checks for locked doors, and potentially unlocks them.
22427 // Only looks at `hero_screen`.
22428 14283254 void HeroClass::checklocked()
22429 {
22430
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268301 times.
14283254 if(toogam) return; //Walk through walls.
22431
2/2
✓ Branch 0 taken 8012300 times.
✓ Branch 1 taken 6256001 times.
14268301 if(!isdungeon(hero_screen)) return;
22432
4/4
✓ Branch 0 taken 6203749 times.
✓ Branch 1 taken 52252 times.
✓ Branch 2 taken 12798 times.
✓ Branch 3 taken 6190951 times.
6256001 if( !diagonalMovement && pushing!=8) return;
22433 //This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
22434
4/4
✓ Branch 0 taken 52252 times.
✓ Branch 1 taken 12798 times.
✓ Branch 2 taken 2677 times.
✓ Branch 3 taken 49575 times.
65050 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
22435
22436 46425 auto [offx, offy] = translate_screen_coordinates_to_world(hero_screen);
22437 30950 int x = this->x - offx;
22438 30950 int y = this->y - offy;
22439
22440 15475 optional<int> openDir;
22441
4/6
✓ Branch 0 taken 12798 times.
✓ Branch 1 taken 2677 times.
✓ Branch 2 taken 12798 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12798 times.
15475 if ( diagonalMovement || NO_GRIDLOCK)
22442 {
22443
8/8
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 2533 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 32 times.
2677 if(y <= 32 && x >= 112 && x <= 128 && Y_DIR(dir) == up)
22444 32 openDir = up;
22445
8/8
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 2324 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 33 times.
2645 else if(y >= 128 && x >= 112 && x <= 128 && Y_DIR(dir) == down)
22446 33 openDir = down;
22447
5/8
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 1149 times.
✓ Branch 2 taken 272 times.
✓ Branch 3 taken 1191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 272 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2612 else if(y > 72 && y < 88 && x <= 32 && X_DIR(dir) == left)
22448 openDir = left;
22449
5/8
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 1149 times.
✓ Branch 2 taken 272 times.
✓ Branch 3 taken 1191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 272 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2612 else if(y > 72 && y < 88 && x >= 208 && X_DIR(dir) == right)
22450 openDir = right;
22451 2677 }
22452 else
22453 {
22454
6/6
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 11047 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 1277 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 413 times.
12798 if(y <= 32 && x == 120 && Y_DIR(dir) == up)
22455 413 openDir = up;
22456
6/6
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 1554 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 227 times.
12385 else if(y >= 128 && x == 120 && Y_DIR(dir) == down)
22457 227 openDir = down;
22458
6/6
✓ Branch 0 taken 1831 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 1492 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 225 times.
12158 else if(y == 80 && x <= 32 && X_DIR(dir) == left)
22459 225 openDir = left;
22460
6/6
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 1183 times.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 356 times.
11933 else if(y == 80 && x >= 208 && X_DIR(dir) == right)
22461 356 openDir = right;
22462 }
22463
22464
2/2
✓ Branch 0 taken 14189 times.
✓ Branch 1 taken 1286 times.
15475 if(openDir)
22465 {
22466 1286 int d = *openDir;
22467
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 922 times.
1286 if (hero_scr->door[d]==dLOCKED)
22468 {
22469
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 14 times.
364 if(usekey())
22470 {
22471 350 putdoor(hero_scr, scrollbuf, d, dUNLOCKED);
22472 350 hero_scr->door[d]=dUNLOCKED;
22473 350 set_doorstate(hero_screen, d);
22474 350 sfx(WAV_DOOR);
22475 350 markBmap();
22476
22477 // set_doorstate updates the door state of the opposite screen too, but it doesn't
22478 // update anything for the current region. Do that here.
22479
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if (mapscr* opp_scr = get_scr_current_region_dir(hero_screen, (direction)d))
22480 {
22481 if (opp_scr->door[d^1] == dLOCKED)
22482 {
22483 opp_scr->door[d^1] = dUNLOCKED;
22484 putdoor(opp_scr, scrollbuf, d^1, dUNLOCKED);
22485 }
22486 }
22487 350 }
22488 14 else return;
22489 350 }
22490
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 56 times.
922 else if(hero_scr->door[d]==dBOSS)
22491 {
22492
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 5 times.
56 if(game->lvlitems[dlevel]&liBOSSKEY)
22493 {
22494 51 putdoor(hero_scr, scrollbuf, d, dOPENBOSS);
22495 51 hero_scr->door[d]=dOPENBOSS;
22496 51 set_doorstate(hero_screen, d);
22497 51 sfx(WAV_DOOR);
22498 51 markBmap();
22499
22500 // set_doorstate updates the door state of the opposite screen too, but it doesn't
22501 // update anything for the current region. Do that here.
22502
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if (mapscr* opp_scr = get_scr_current_region_dir(hero_screen, (direction)d))
22503 {
22504 if (opp_scr->door[d^1] == dBOSS)
22505 {
22506 opp_scr->door[d^1] = dOPENBOSS;
22507 putdoor(opp_scr, scrollbuf, d^1, dOPENBOSS);
22508 }
22509 }
22510
22511 // Run Boss Key Script
22512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3468 times.
3468 for ( int32_t q = 0; q < MAXITEMS; ++q )
22513
2/2
✓ Branch 0 taken 3417 times.
✓ Branch 1 taken 51 times.
3468 if ( itemsbuf[q].family == itype_bosskey )
22514 {
22515
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if (itemsbuf[q].script && !(FFCore.doscript(ScriptType::Item, q) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
22516 {
22517 FFCore.reset_script_engine_data(ScriptType::Item, q);
22518 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q);
22519 FFCore.deallocateAllScriptOwned(ScriptType::Item, q);
22520 }
22521 51 break;
22522 }
22523 51 }
22524 5 else return;
22525 51 }
22526 1267 }
22527 14283254 }
22528
22529 14283254 void HeroClass::checkswordtap()
22530 {
22531
6/6
✓ Branch 0 taken 6928894 times.
✓ Branch 1 taken 7354360 times.
✓ Branch 2 taken 40969 times.
✓ Branch 3 taken 6887925 times.
✓ Branch 4 taken 40006 times.
✓ Branch 5 taken 963 times.
14283254 if(attack!=wSword || charging<=0 || pushing<8) return;
22532
22533 963 int32_t bx=x;
22534 963 int32_t by=y+8;
22535
22536
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 307 times.
✓ Branch 4 taken 262 times.
963 switch(dir)
22537 {
22538 case up:
22539
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 65 times.
282 if(!Up()) return;
22540
22541 217 by-=16;
22542 217 break;
22543
22544 case down:
22545
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 20 times.
112 if(!Down()) return;
22546
22547 92 by+=16;
22548 92 bx+=8;
22549 92 break;
22550
22551 case left:
22552
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 139 times.
307 if(!Left()) return;
22553
22554 168 bx-=16;
22555 168 by+=8;
22556 168 break;
22557
22558 case right:
22559
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 72 times.
262 if(!Right()) return;
22560
22561 190 bx+=16;
22562 190 by+=8;
22563 190 break;
22564 }
22565
22566
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 513 times.
✓ Branch 5 taken 154 times.
667 if(!_walkflag(bx,by,0,STANDING_Z_STATE)) return;
22567
22568 513 attackclk=SWORDTAPFRAME;
22569 513 pushing=-8; //16 frames between taps
22570 513 tapping=true;
22571
22572
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 500 times.
513 if (!isCuttableType(COMBOTYPE(bx, by)))
22573 {
22574 500 int tap_sfx = -1;
22575 500 bool hollow = false;
22576
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 3500 times.
4000 for(int lyr = 6; lyr >= 0; --lyr)
22577 {
22578 3500 auto rpos_handle_lyr = get_rpos_handle_for_world_xy(bx, by, lyr);
22579 3500 auto& cmb = rpos_handle_lyr.combo();
22580
1/2
✓ Branch 0 taken 3500 times.
✗ Branch 1 not taken.
3500 if(cmb.sfx_tap)
22581 {
22582 tap_sfx = cmb.sfx_tap;
22583 break;
22584 }
22585
22586
3/4
✓ Branch 0 taken 3491 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3491 times.
6991 if(rpos_handle_lyr.sflag() == mfBOMB || rpos_handle_lyr.sflag() == mfSBOMB
22587
2/4
✓ Branch 0 taken 3491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3491 times.
✗ Branch 3 not taken.
3491 || cmb.flag == mfBOMB || cmb.flag == mfSBOMB)
22588 9 hollow = true;
22589 3500 }
22590
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(tap_sfx < 0 && get_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX))
22591 {
22592
4/12
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 491 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 491 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
500 if(hollow || (!is_in_scrolling_region() && origin_scr->door[dir]==dBOMB && ((dir==up||dir==down)
22593 ? (bx>=112 && bx<144 && (by>=144 || by<=32))
22594 : by>=72 && by<104 && (bx>=224 || bx<=32))))
22595 9 tap_sfx = QMisc.miscsfx[sfxTAP_HOLLOW];
22596 500 }
22597
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 491 times.
500 if(tap_sfx < 0)
22598 491 tap_sfx = QMisc.miscsfx[sfxTAP];
22599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 if(tap_sfx)
22600 500 sfx(tap_sfx,pan(x.getInt()));
22601 500 }
22602 14283254 }
22603
22604 27606 void HeroClass::fairycircle(int32_t type)
22605 {
22606
2/2
✓ Branch 0 taken 23253 times.
✓ Branch 1 taken 4353 times.
27606 if(fairyclk==0)
22607 {
22608
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4333 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 19 times.
4353 switch(type)
22609 {
22610 case REFILL_LIFE:
22611
2/2
✓ Branch 0 taken 4177 times.
✓ Branch 1 taken 156 times.
4333 if(didstuff&did_fairy) return;
22612
22613 156 didstuff|=did_fairy;
22614 156 break;
22615
22616 case REFILL_MAGIC:
22617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(didstuff&did_magic) return;
22618
22619 1 didstuff|=did_magic;
22620 1 break;
22621
22622 case REFILL_ALL:
22623
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(didstuff&did_all) return;
22624
22625 2 didstuff|=did_all;
22626 2 }
22627
22628 159 refill_what=type;
22629 159 refill_why=REFILL_FAIRY;
22630 159 StartRefill(type);
22631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
22632 159 else {action=freeze; FFCore.setHeroAction(freeze);}
22633 159 holdclk=0;
22634 159 hopclk=0;
22635 159 }
22636
22637 23412 ++fairyclk;
22638
22639
2/2
✓ Branch 0 taken 10557 times.
✓ Branch 1 taken 12855 times.
23412 if(refilling!=REFILL_FAIRYDONE)
22640 {
22641
2/2
✓ Branch 0 taken 10398 times.
✓ Branch 1 taken 159 times.
10557 if(!refill())
22642 159 refilling=REFILL_FAIRYDONE;
22643 10557 }
22644
22645
2/2
✓ Branch 0 taken 12697 times.
✓ Branch 1 taken 158 times.
12855 else if(++holdclk>80)
22646 {
22647 158 reset_swordcharge();
22648 158 attackclk=0;
22649 158 action=none; FFCore.setHeroAction(none);
22650 158 fairyclk=0;
22651 158 holdclk=0;
22652 158 refill_why = 0;
22653 158 refilling=REFILL_NONE;
22654 158 map_bkgsfx(true);
22655 158 }
22656 27606 }
22657
22658 1414084 int32_t touchcombo(int32_t x,int32_t y)
22659 {
22660
2/2
✓ Branch 0 taken 2828100 times.
✓ Branch 1 taken 1414016 times.
4242116 for (int32_t i = 0; i <= 1; ++i)
22661 {
22662
2/2
✓ Branch 0 taken 2623300 times.
✓ Branch 1 taken 204800 times.
2828100 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22663 {
22664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2623300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2623300 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,i)) return 0;
22665 2623300 }
22666 else
22667 {
22668
4/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 204699 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 68 times.
204800 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,i)) return 0;
22669 }
22670 2828032 }
22671
2/2
✓ Branch 0 taken 1412378 times.
✓ Branch 1 taken 1638 times.
1414016 if (!_effectflag(x,y,1, -1)) return 0;
22672 1412378 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
22673
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1412330 times.
1412378 if(cmb.only_gentrig)
22674 48 return 0;
22675
3/3
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 1407137 times.
✓ Branch 2 taken 1951 times.
1412330 switch(cmb.type)
22676 {
22677 case cBSGRAVE:
22678 case cGRAVE:
22679
3/4
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 987 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2255 times.
3242 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
22680 {
22681 987 break;
22682 }
22683
22684 [[fallthrough]];
22685 case cARMOS:
22686 {
22687 4206 return cmb.type;
22688 }
22689 }
22690
22691 1408124 return 0;
22692 1414084 }
22693
22694 static int32_t GridX(int32_t x)
22695 {
22696 return (x >> 4) << 4;
22697 }
22698
22699 //Snaps 'y' to the combo grid
22700 //Equivalent to calling ComboY(ComboAt(foo,y));
22701 static int32_t GridY(int32_t y)
22702 {
22703 return (y >> 4) << 4;
22704 }
22705
22706 9 static int32_t beamGrabComboFromPos(rpos_t rpos, int32_t type)
22707 {
22708
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 for (int lyr = 6; lyr >= 0; --lyr)
22709 {
22710 63 auto rpos_handle = get_rpos_handle(rpos, lyr);
22711
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 54 times.
63 if (rpos_handle.ctype() == type)
22712 9 return rpos_handle.data();
22713 54 }
22714
22715 return -1;
22716 9 }
22717
22718 typedef word spot_t;
22719 static std::vector<int32_t> typeMap;
22720 static std::vector<int32_t> customTypeMap;
22721 static std::vector<int32_t> istrig;
22722 // static std::map<int32_t, std::map<size_t, word>> MAPS_prism_dir_seen_map;
22723 static rpos_t beam_hero_rpos = rpos_t::None;
22724 static const int32_t SPTYPE_SOLID = -1;
22725 enum
22726 {
22727 beamoffs_gr, beamoffs_up, beamoffs_down, beamoffs_left, beamoffs_right,
22728 beamoffs_uleft, beamoffs_uright, beamoffs_dleft, beamoffs_dright, beamoffs_vert,
22729 beamoffs_horz, beamoffs_notup, beamoffs_notdown, beamoffs_notleft, beamoffs_notright,
22730 beamoffs_all, beamoffs_max
22731 };
22732 struct lightbeam_xy
22733 {
22734 int16_t x;
22735 int16_t y;
22736 lightbeam_xy(int32_t nx, int32_t ny)
22737 {
22738 x = vbound(nx,-32768,32767);
22739 y = vbound(ny,-32768,32767);
22740 }
22741 lightbeam_xy(dword ffpos)
22742 {
22743 x = int16_t(ffpos >> 16);
22744 y = int16_t(ffpos & 0xFFFF);
22745 }
22746 bool valid() const
22747 {
22748 return valid(x,y);
22749 }
22750 void bound()
22751 {
22752 x = vbound(x,0-16,world_w-1+16);
22753 y = vbound(y,0-16,world_h-1+16);
22754 }
22755 dword ffpos() const
22756 {
22757 return (word(x)<<16)|word(y&0xFFFF);
22758 }
22759 rpos_t pos() const
22760 {
22761 return COMBOPOS_REGION(vbound(x,0,world_w-1),vbound(y,0,world_h-1));
22762 }
22763 bool herocollide(byte beamwid)
22764 {
22765 int bx = x-beamwid/2, by = y-beamwid/2;
22766 int hx = Hero.x.getInt(), hy = Hero.y.getInt();
22767 return hx+15 >= bx && hx < bx+beamwid
22768 && hy+15 >= by && hy < by+beamwid;
22769 }
22770 static bool valid(int32_t x, int32_t y)
22771 {
22772 return x+16 >= 0 && x-16 < world_w && y+16 >= 0 && y-16 < world_h;
22773 }
22774 };
22775 #define SP_VISITED 0x1
22776 #define SP_FLAGS 0x01E
22777 #define SP_GOFLAGS 0x1E0
22778 #define SP_MASK (SP_VISITED|SP_FLAGS)
22779 #define SP_FLAG(dir) (0x2<<dir)
22780 #define SP_GOFLAG(dir) (0x20<<dir)
22781 #define BEAM_AGE_LIMIT 512
22782
22783 14283 static void handleBeam(spot_t* grid, size_t age, byte spotdir, rpos_t rpos, byte set, bool block, bool refl)
22784 {
22785
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 6663 times.
14283 if(spotdir > 3) return; //invalid dir
22786
22787 6663 int combos_wide = cur_region.screen_width * 16;
22788 6663 int combos_tall = cur_region.screen_height * 11;
22789
2/2
✓ Branch 0 taken 5429 times.
✓ Branch 1 taken 1234 times.
6663 int32_t trigflag = set ? (1 << (set-1)) : ~0;
22790 6663 bool doAge = true;
22791 6663 spot_t f = 0;
22792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70632 times.
70632 while (rpos < region_max_rpos)
22793 {
22794 140809 auto [x, y] = COMBOXY_REGION_INDEX(rpos);
22795
22796 70632 f = SP_GOFLAG(spotdir);
22797
2/2
✓ Branch 0 taken 70177 times.
✓ Branch 1 taken 455 times.
70632 if((grid[(int)rpos] & f) == f)
22798 455 return;
22799 70177 else grid[(int)rpos] |= f;
22800 70177 f = SP_FLAG(spotdir);
22801
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 70024 times.
70177 if((grid[(int)rpos] & f) != f)
22802 {
22803 70024 grid[(int)rpos] |= f;
22804 70024 istrig[(int)rpos] |= trigflag;
22805 70024 doAge = false;
22806 70024 age = 0;
22807 70024 }
22808
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16931 times.
✓ Branch 2 taken 9603 times.
✓ Branch 3 taken 23595 times.
✓ Branch 4 taken 20048 times.
70177 switch(spotdir)
22809 {
22810 case up:
22811 16931 y -= 1;
22812 16931 break;
22813 case down:
22814 9603 y += 1;
22815 9603 break;
22816 case left:
22817 23595 x -= 1;
22818 23595 break;
22819 case right:
22820 20048 x += 1;
22821 20048 break;
22822 }
22823
22824
4/8
✓ Branch 0 taken 70177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70177 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70177 times.
70177 if (!(x >= 0 && x < combos_wide && y >= 0 && y < combos_tall)) return;
22825
22826 140354 rpos = COMBOPOS_REGION_INDEX(x, y);
22827
22828
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 63969 times.
70177 switch (typeMap[(int)rpos])
22829 {
22830 case SPTYPE_SOLID: case cBLOCKALL:
22831 6208 return;
22832 }
22833
22834
3/6
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63969 if (rpos == beam_hero_rpos && block && spotdir == oppositeDir[Hero.getDir()])
22835 return;
22836
22837 63969 f = SP_FLAG(oppositeDir[spotdir]);
22838
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if((grid[(int)rpos] & f) != f)
22839 {
22840 63816 grid[(int)rpos] |= f;
22841 63816 istrig[(int)rpos] |= trigflag;
22842 63816 doAge = false;
22843 63816 age = 0;
22844 63816 }
22845
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if(doAge)
22846 {
22847
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(++age > BEAM_AGE_LIMIT)
22848 return;
22849 153 }
22850 63816 else doAge = true;
22851
22852
4/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✓ Branch 2 taken 147 times.
✓ Branch 3 taken 728 times.
63969 if (rpos == beam_hero_rpos && refl)
22853 728 spotdir = Hero.getDir();
22854
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9088 times.
✓ Branch 2 taken 7781 times.
✓ Branch 3 taken 46363 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
63241 else switch (typeMap[(int)rpos])
22855 {
22856 case cLIGHTTARGET:
22857 {
22858 9 int cid = beamGrabComboFromPos(rpos, cLIGHTTARGET);
22859
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
22860 return;
22861
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
22862 6 spotdir = oppositeDir[spotdir];
22863 9 break;
22864 }
22865 case cMIRROR:
22866 spotdir = oppositeDir[spotdir];
22867 break;
22868 case cMIRRORSLASH:
22869
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2991 times.
✓ Branch 2 taken 3402 times.
✓ Branch 3 taken 1726 times.
✓ Branch 4 taken 969 times.
9088 switch(spotdir)
22870 {
22871 case up:
22872 2991 spotdir = right; break;
22873 case right:
22874 3402 spotdir = up; break;
22875 case down:
22876 1726 spotdir = left; break;
22877 case left:
22878 969 spotdir = down; break;
22879 }
22880 9088 break;
22881 case cMIRRORBACKSLASH:
22882
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1927 times.
✓ Branch 2 taken 1814 times.
✓ Branch 3 taken 1522 times.
✓ Branch 4 taken 2518 times.
7781 switch(spotdir)
22883 {
22884 case up:
22885 1927 spotdir = left; break;
22886 case left:
22887 1814 spotdir = up; break;
22888 case down:
22889 1522 spotdir = right; break;
22890 case right:
22891 2518 spotdir = down; break;
22892 }
22893 7781 break;
22894 case cMAGICPRISM:
22895 for(byte d = 0; d < 4; ++d)
22896 {
22897 if(d == oppositeDir[spotdir]) continue;
22898 handleBeam(grid, age, d, rpos, set, block, refl);
22899 }
22900 return;
22901 case cMAGICPRISM4:
22902 for(byte d = 0; d < 4; ++d)
22903 {
22904 handleBeam(grid, age, d, rpos, set, block, refl);
22905 }
22906 return;
22907 case cMIRRORNEW:
22908 {
22909 auto cid = customTypeMap[(int)rpos];
22910 if(unsigned(cid) >= MAXCOMBOS) break;
22911 newcombo const& cmb = combobuf[cid];
22912 byte newdir = cmb.attribytes[spotdir];
22913 if(newdir > 7) return;
22914 if(newdir > 3) break;
22915 spotdir = newdir;
22916 break;
22917 }
22918 }
22919 }
22920 14283 }
22921
22922 static void handleFFBeam(std::map<dword,spot_t>& grid, size_t age, byte spotdir, lightbeam_xy curxy, byte set, bool block, bool refl, byte beamwid)
22923 {
22924 if(spotdir > 3) return; //invalid dir
22925 int32_t trigflag = set ? (1 << (set-1)) : ~0;
22926 bool doAge = true;
22927 byte f = 0;
22928 while(curxy.valid())
22929 {
22930 f = SP_FLAG(spotdir);
22931 if((grid[curxy.ffpos()] & f) != f)
22932 {
22933 grid[curxy.ffpos()] |= f;
22934 istrig[(int)curxy.pos()] |= trigflag;
22935 doAge = false;
22936 age = 0;
22937 }
22938 switch(spotdir)
22939 {
22940 case up:
22941 curxy.y -= 16;
22942 break;
22943 case down:
22944 curxy.y += 16;
22945 break;
22946 case left:
22947 curxy.x -= 16;
22948 break;
22949 case right:
22950 curxy.x += 16;
22951 break;
22952 }
22953 auto curpos = curxy.pos();
22954 switch(typeMap[(int)curpos])
22955 {
22956 case SPTYPE_SOLID: case cBLOCKALL:
22957 return;
22958 case cMIRRORNEW:
22959 {
22960 auto cid = customTypeMap[(int)curpos];
22961 if(unsigned(cid) >= MAXCOMBOS) break;
22962 newcombo const& cmb = combobuf[cid];
22963 byte newdir = cmb.attribytes[spotdir];
22964 if(newdir > 7) return;
22965 break;
22966 }
22967 }
22968 bool collided_hero = beam_hero_rpos != rpos_t::None && curxy.herocollide(beamwid);
22969 if(block && (spotdir == oppositeDir[Hero.getDir()]) && collided_hero)
22970 return;
22971
22972 f = SP_FLAG(oppositeDir[spotdir]);
22973 if((grid[curxy.ffpos()] & f) != f)
22974 {
22975 grid[curxy.ffpos()] |= f;
22976 istrig[(int)curpos] |= trigflag;
22977 doAge = false;
22978 age = 0;
22979 }
22980 if(!curxy.valid()) return;
22981 if(doAge)
22982 {
22983 if(++age > BEAM_AGE_LIMIT)
22984 return;
22985 }
22986 else doAge = true;
22987
22988 if(refl && collided_hero)
22989 spotdir = Hero.getDir();
22990 else switch(typeMap[(int)curpos])
22991 {
22992 case cLIGHTTARGET:
22993 {
22994 int cid = beamGrabComboFromPos(curpos, cLIGHTTARGET);
22995 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
22996 return;
22997 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
22998 spotdir = oppositeDir[spotdir];
22999 break;
23000 }
23001 case cMIRROR:
23002 spotdir = oppositeDir[spotdir];
23003 break;
23004 case cMIRRORSLASH:
23005 switch(spotdir)
23006 {
23007 case up:
23008 spotdir = right; break;
23009 case right:
23010 spotdir = up; break;
23011 case down:
23012 spotdir = left; break;
23013 case left:
23014 spotdir = down; break;
23015 }
23016 break;
23017 case cMIRRORBACKSLASH:
23018 switch(spotdir)
23019 {
23020 case up:
23021 spotdir = left; break;
23022 case left:
23023 spotdir = up; break;
23024 case down:
23025 spotdir = right; break;
23026 case right:
23027 spotdir = down; break;
23028 }
23029 break;
23030 case cMAGICPRISM:
23031 for(byte d = 0; d < 4; ++d)
23032 {
23033 if(d == oppositeDir[spotdir]) continue;
23034 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23035 }
23036 return;
23037 case cMAGICPRISM4:
23038 for(byte d = 0; d < 4; ++d)
23039 {
23040 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23041 }
23042 return;
23043 case cMIRRORNEW:
23044 {
23045 auto cid = customTypeMap[(int)curpos];
23046 if(unsigned(cid) >= MAXCOMBOS) break;
23047 newcombo const& cmb = combobuf[cid];
23048 byte newdir = cmb.attribytes[spotdir];
23049 if(newdir > 3) break;
23050 spotdir = newdir;
23051 break;
23052 }
23053 }
23054 }
23055 }
23056
23057 #define BEAMID_COLOR0 (1<<24) //must have rightmost 24 bits empty
23058 14283 static int get_beamid(newcombo const& cmb)
23059 {
23060 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
23061
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
14283 if(cmb.usrflags&cflag1) //use tile/cset style
23062 1234 return std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24;
23063 else //use 3-color style
23064 {
23065 13049 auto id = -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
23066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 if(!id) //0 would clash with the tile/cset style
23067 id = BEAMID_COLOR0;
23068 13049 return id;
23069 }
23070 14283 }
23071 14283 static bool launch_lightbeam(const rpos_handle_t& rpos_handle, std::map<int32_t, spot_t*>& maps, bool refl, bool block)
23072 {
23073 14283 auto& cmb = rpos_handle.combo();
23074 14283 int32_t id = get_beamid(cmb);
23075 //Get the grid array for this tile/color
23076 spot_t* grid;
23077
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if(maps[id])
23078 grid = maps[id];
23079 else
23080 {
23081 14283 maps[id] = grid = new spot_t[region_num_rpos];
23082 14283 memset(grid, 0, sizeof(spot_t)*region_num_rpos);
23083 }
23084 14283 byte spotdir = cmb.attribytes[0];
23085
2/2
✓ Branch 0 taken 3861 times.
✓ Branch 1 taken 10422 times.
14283 if(spotdir > 3)
23086 {
23087 10422 grid[(int)rpos_handle.rpos] |= SP_VISITED;
23088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10422 times.
10422 istrig[(int)rpos_handle.rpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23089 10422 }
23090
4/4
✓ Branch 0 taken 10892 times.
✓ Branch 1 taken 3391 times.
✓ Branch 2 taken 8090 times.
✓ Branch 3 taken 2802 times.
14283 if(refl && rpos_handle.rpos == beam_hero_rpos)
23091 {
23092 2802 spotdir = Hero.getDir();
23093 2802 }
23094 14283 handleBeam(grid, 0, spotdir, rpos_handle.rpos, cmb.attribytes[4], block, refl);
23095 14283 return true;
23096 }
23097
23098 static bool launch_fflightbeam(ffcdata const& ffc,
23099 std::map<int32_t, std::map<dword,spot_t>>& ffmaps, bool refl, bool block)
23100 {
23101 newcombo const& cmb = combobuf[ffc.data];
23102 int32_t id = get_beamid(cmb);
23103 //Get the grid array for this tile/color
23104 std::map<dword,spot_t>& grid = ffmaps[id]; // grid of (x<<16)|(y&0xFFFF)
23105 byte spotdir = cmb.attribytes[0];
23106 lightbeam_xy sxy(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23107 if(spotdir > 3 && sxy.valid())
23108 {
23109 grid[sxy.ffpos()] |= SP_VISITED;
23110 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23111 istrig[(int)sxy.pos()] |= trigflag;
23112 }
23113 auto beamwid = cmb.attribytes[5] < 1 ? 8 : cmb.attribytes[5];
23114 if(refl && beam_hero_rpos != rpos_t::None && sxy.herocollide(beamwid))
23115 {
23116 spotdir = Hero.getDir();
23117 }
23118 switch(spotdir)
23119 {
23120 case up:
23121 sxy.y = zc_min(world_h-1,sxy.y);
23122 break;
23123 case down:
23124 sxy.y = zc_max(0,sxy.y);
23125 break;
23126 case left:
23127 sxy.x = zc_min(world_w-1,sxy.x);
23128 break;
23129 case right:
23130 sxy.x = zc_max(0,sxy.x);
23131 break;
23132 }
23133 handleFFBeam(grid, 0, spotdir, sxy, cmb.attribytes[4], block, refl, beamwid);
23134 return true;
23135 }
23136
23137 14283 static BITMAP* generate_beam_bitmap(int32_t id)
23138 {
23139 14283 BITMAP* cbmp = create_bitmap_ex(8, 16*beamoffs_max, 16);
23140 14283 clear_bitmap(cbmp);
23141
3/4
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
14283 if(id < 0 || id == BEAMID_COLOR0)
23142 {
23143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 int cid = (id == BEAMID_COLOR0) ? 0 : abs(id);
23144 13049 byte c_inner = (cid & 0x0000FF);
23145 13049 byte c_middle = (cid & 0x00FF00)>>8;
23146 13049 byte c_outter = (cid & 0xFF0000)>>16;
23147
2/2
✓ Branch 0 taken 195735 times.
✓ Branch 1 taken 13049 times.
208784 for(size_t q = 1; q < beamoffs_max; ++q)
23148 {
23149 195735 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
23150 195735 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
23151 195735 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
23152 195735 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
23153 195735 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
23154 195735 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
23155 195735 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
23156 195735 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
23157 195735 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
23158 195735 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
23159 195735 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
23160 195735 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
23161 195735 }
23162 //beamoffs_gr
23163 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 7, c_outter);
23164 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 7, c_outter);
23165 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 7, c_outter);
23166 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 7, c_outter);
23167 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 5, c_middle);
23168 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 5, c_middle);
23169 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 5, c_middle);
23170 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 5, c_middle);
23171 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 3, c_inner);
23172 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 3, c_inner);
23173 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 3, c_inner);
23174 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 3, c_inner);
23175 //beamoffs_up
23176 13049 rectfill(cbmp, 16*beamoffs_up+4, 0, 16*beamoffs_up+11, 7, c_outter);
23177 13049 rectfill(cbmp, 16*beamoffs_up+6, 0, 16*beamoffs_up+9, 7, c_middle);
23178 13049 rectfill(cbmp, 16*beamoffs_up+7, 0, 16*beamoffs_up+8, 7, c_inner);
23179 //beamoffs_down
23180 13049 rectfill(cbmp, 16*beamoffs_down+4, 8, 16*beamoffs_down+11, 15, c_outter);
23181 13049 rectfill(cbmp, 16*beamoffs_down+6, 8, 16*beamoffs_down+9, 15, c_middle);
23182 13049 rectfill(cbmp, 16*beamoffs_down+7, 8, 16*beamoffs_down+8, 15, c_inner);
23183 //beamoffs_left
23184 13049 rectfill(cbmp, 16*beamoffs_left, 4, 16*beamoffs_left+7, 11, c_outter);
23185 13049 rectfill(cbmp, 16*beamoffs_left, 6, 16*beamoffs_left+7, 9, c_middle);
23186 13049 rectfill(cbmp, 16*beamoffs_left, 7, 16*beamoffs_left+7, 8, c_inner);
23187 //beamoffs_right
23188 13049 rectfill(cbmp, 16*beamoffs_right+8, 4, 16*beamoffs_right+15, 11, c_outter);
23189 13049 rectfill(cbmp, 16*beamoffs_right+8, 6, 16*beamoffs_right+15, 9, c_middle);
23190 13049 rectfill(cbmp, 16*beamoffs_right+8, 7, 16*beamoffs_right+15, 8, c_inner);
23191 //beamoffs_uleft
23192 13049 rectfill(cbmp, 16*beamoffs_uleft+4, 0, 16*beamoffs_uleft+11, 7, c_outter);
23193 13049 rectfill(cbmp, 16*beamoffs_uleft, 4, 16*beamoffs_uleft+7, 11, c_outter);
23194 13049 rectfill(cbmp, 16*beamoffs_uleft, 6, 16*beamoffs_uleft+7, 9, c_middle);
23195 13049 rectfill(cbmp, 16*beamoffs_uleft+6, 0, 16*beamoffs_uleft+9, 7, c_middle);
23196 13049 rectfill(cbmp, 16*beamoffs_uleft+7, 0, 16*beamoffs_uleft+8, 7, c_inner);
23197 13049 rectfill(cbmp, 16*beamoffs_uleft, 7, 16*beamoffs_uleft+7, 8, c_inner);
23198 //beamoffs_uright
23199 13049 rectfill(cbmp, 16*beamoffs_uright+4, 0, 16*beamoffs_uright+11, 7, c_outter);
23200 13049 rectfill(cbmp, 16*beamoffs_uright+8, 4, 16*beamoffs_uright+15, 11, c_outter);
23201 13049 rectfill(cbmp, 16*beamoffs_uright+8, 6, 16*beamoffs_uright+15, 9, c_middle);
23202 13049 rectfill(cbmp, 16*beamoffs_uright+6, 0, 16*beamoffs_uright+9, 7, c_middle);
23203 13049 rectfill(cbmp, 16*beamoffs_uright+7, 0, 16*beamoffs_uright+8, 7, c_inner);
23204 13049 rectfill(cbmp, 16*beamoffs_uright+8, 7, 16*beamoffs_uright+15, 8, c_inner);
23205 //beamoffs_dleft
23206 13049 rectfill(cbmp, 16*beamoffs_dleft+4, 8, 16*beamoffs_dleft+11, 15, c_outter);
23207 13049 rectfill(cbmp, 16*beamoffs_dleft, 4, 16*beamoffs_dleft+7, 11, c_outter);
23208 13049 rectfill(cbmp, 16*beamoffs_dleft, 6, 16*beamoffs_dleft+7, 9, c_middle);
23209 13049 rectfill(cbmp, 16*beamoffs_dleft+6, 8, 16*beamoffs_dleft+9, 15, c_middle);
23210 13049 rectfill(cbmp, 16*beamoffs_dleft+7, 8, 16*beamoffs_dleft+8, 15, c_inner);
23211 13049 rectfill(cbmp, 16*beamoffs_dleft, 7, 16*beamoffs_dleft+7, 8, c_inner);
23212 //beamoffs_dright
23213 13049 rectfill(cbmp, 16*beamoffs_dright+4, 8, 16*beamoffs_dright+11, 15, c_outter);
23214 13049 rectfill(cbmp, 16*beamoffs_dright+8, 4, 16*beamoffs_dright+15, 11, c_outter);
23215 13049 rectfill(cbmp, 16*beamoffs_dright+8, 6, 16*beamoffs_dright+15, 9, c_middle);
23216 13049 rectfill(cbmp, 16*beamoffs_dright+6, 8, 16*beamoffs_dright+9, 15, c_middle);
23217 13049 rectfill(cbmp, 16*beamoffs_dright+7, 8, 16*beamoffs_dright+8, 15, c_inner);
23218 13049 rectfill(cbmp, 16*beamoffs_dright+8, 7, 16*beamoffs_dright+15, 8, c_inner);
23219 //beamoffs_vert
23220 13049 rectfill(cbmp, 16*beamoffs_vert+4, 0, 16*beamoffs_vert+11, 15, c_outter);
23221 13049 rectfill(cbmp, 16*beamoffs_vert+6, 0, 16*beamoffs_vert+9, 15, c_middle);
23222 13049 rectfill(cbmp, 16*beamoffs_vert+7, 0, 16*beamoffs_vert+8, 15, c_inner);
23223 //beamoffs_horz
23224 13049 rectfill(cbmp, 16*beamoffs_horz, 4, 16*beamoffs_horz+15, 11, c_outter);
23225 13049 rectfill(cbmp, 16*beamoffs_horz, 6, 16*beamoffs_horz+15, 9, c_middle);
23226 13049 rectfill(cbmp, 16*beamoffs_horz, 7, 16*beamoffs_horz+15, 8, c_inner);
23227 //beamoffs_notup
23228 13049 rectfill(cbmp, 16*beamoffs_notup, 4, 16*beamoffs_notup+15, 11, c_outter);
23229 13049 rectfill(cbmp, 16*beamoffs_notup+4, 8, 16*beamoffs_notup+11, 15, c_outter);
23230 13049 rectfill(cbmp, 16*beamoffs_notup+6, 8, 16*beamoffs_notup+9, 15, c_middle);
23231 13049 rectfill(cbmp, 16*beamoffs_notup, 6, 16*beamoffs_notup+15, 9, c_middle);
23232 13049 rectfill(cbmp, 16*beamoffs_notup, 7, 16*beamoffs_notup+15, 8, c_inner);
23233 13049 rectfill(cbmp, 16*beamoffs_notup+7, 8, 16*beamoffs_notup+8, 15, c_inner);
23234 //beamoffs_notdown
23235 13049 rectfill(cbmp, 16*beamoffs_notdown, 4, 16*beamoffs_notdown+15, 11, c_outter);
23236 13049 rectfill(cbmp, 16*beamoffs_notdown+4, 0, 16*beamoffs_notdown+11, 7, c_outter);
23237 13049 rectfill(cbmp, 16*beamoffs_notdown+6, 0, 16*beamoffs_notdown+9, 7, c_middle);
23238 13049 rectfill(cbmp, 16*beamoffs_notdown, 6, 16*beamoffs_notdown+15, 9, c_middle);
23239 13049 rectfill(cbmp, 16*beamoffs_notdown, 7, 16*beamoffs_notdown+15, 8, c_inner);
23240 13049 rectfill(cbmp, 16*beamoffs_notdown+7, 0, 16*beamoffs_notdown+8, 7, c_inner);
23241 //beamoffs_notleft
23242 13049 rectfill(cbmp, 16*beamoffs_notleft+4, 0, 16*beamoffs_notleft+11, 15, c_outter);
23243 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 4, 16*beamoffs_notleft+15, 11, c_outter);
23244 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 6, 16*beamoffs_notleft+15, 9, c_middle);
23245 13049 rectfill(cbmp, 16*beamoffs_notleft+6, 0, 16*beamoffs_notleft+9, 15, c_middle);
23246 13049 rectfill(cbmp, 16*beamoffs_notleft+7, 0, 16*beamoffs_notleft+8, 15, c_inner);
23247 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 7, 16*beamoffs_notleft+15, 8, c_inner);
23248 //beamoffs_notright
23249 13049 rectfill(cbmp, 16*beamoffs_notright+4, 0, 16*beamoffs_notright+11, 15, c_outter);
23250 13049 rectfill(cbmp, 16*beamoffs_notright, 4, 16*beamoffs_notright+7, 11, c_outter);
23251 13049 rectfill(cbmp, 16*beamoffs_notright, 6, 16*beamoffs_notright+7, 9, c_middle);
23252 13049 rectfill(cbmp, 16*beamoffs_notright+6, 0, 16*beamoffs_notright+9, 15, c_middle);
23253 13049 rectfill(cbmp, 16*beamoffs_notright+7, 0, 16*beamoffs_notright+8, 15, c_inner);
23254 13049 rectfill(cbmp, 16*beamoffs_notright, 7, 16*beamoffs_notright+7, 8, c_inner);
23255 //beamoffs_all
23256 13049 rectfill(cbmp, 16*beamoffs_all+4, 0, 16*beamoffs_all+11, 15, c_outter);
23257 13049 rectfill(cbmp, 16*beamoffs_all, 4, 16*beamoffs_all+15, 11, c_outter);
23258 13049 rectfill(cbmp, 16*beamoffs_all, 6, 16*beamoffs_all+15, 9, c_middle);
23259 13049 rectfill(cbmp, 16*beamoffs_all+6, 0, 16*beamoffs_all+9, 15, c_middle);
23260 13049 rectfill(cbmp, 16*beamoffs_all+7, 0, 16*beamoffs_all+8, 15, c_inner);
23261 13049 rectfill(cbmp, 16*beamoffs_all, 7, 16*beamoffs_all+15, 8, c_inner);
23262 13049 }
23263 else
23264 {
23265 1234 int32_t tile = (id&0xFFFFFF);
23266 1234 int32_t cs = (id>>24);
23267
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 1234 times.
20978 for(size_t q = 0; q < beamoffs_max; ++q)
23268 19744 puttile16(cbmp, tile+q, q*16, 0, cs, 0);
23269 }
23270 14283 return cbmp;
23271 }
23272
23273 2499525 static int32_t get_beamoffs(spot_t val)
23274 {
23275
12/17
✗ Branch 0 not taken.
✓ Branch 1 taken 2430030 times.
✓ Branch 2 taken 1469 times.
✓ Branch 3 taken 1188 times.
✓ Branch 4 taken 1795 times.
✓ Branch 5 taken 1768 times.
✓ Branch 6 taken 14821 times.
✓ Branch 7 taken 31678 times.
✓ Branch 8 taken 4877 times.
✓ Branch 9 taken 3412 times.
✓ Branch 10 taken 4161 times.
✓ Branch 11 taken 3791 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 535 times.
2499525 switch((val&SP_MASK)>>1)
23276 {
23277 2430030 case 0: default:
23278
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 2422410 times.
2430030 if(val)
23279 7620 return beamoffs_gr;
23280 2422410 return -1;
23281 case 0b0001:
23282 1469 return beamoffs_up;
23283 case 0b0010:
23284 1188 return beamoffs_down;
23285 case 0b0100:
23286 1795 return beamoffs_left;
23287 case 0b1000:
23288 1768 return beamoffs_right;
23289 case 0b0011:
23290 14821 return beamoffs_vert;
23291 case 0b1100:
23292 31678 return beamoffs_horz;
23293 case 0b0101:
23294 4877 return beamoffs_uleft;
23295 case 0b1001:
23296 3412 return beamoffs_uright;
23297 case 0b0110:
23298 4161 return beamoffs_dleft;
23299 case 0b1010:
23300 3791 return beamoffs_dright;
23301 case 0b1110:
23302 return beamoffs_notup;
23303 case 0b1101:
23304 return beamoffs_notdown;
23305 case 0b1011:
23306 return beamoffs_notleft;
23307 case 0b0111:
23308 return beamoffs_notright;
23309 case 0b1111:
23310 535 return beamoffs_all;
23311 }
23312 return -1;
23313 2499525 }
23314
23315 14307770 void HeroClass::handleSpotlights()
23316 {
23317 static bool had_spotlight = true;
23318
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14293487 times.
14307770 if (cpos_exists_spotlight())
23319 {
23320 14283 istrig.clear();
23321 14283 customTypeMap.clear();
23322 14283 typeMap.clear();
23323
23324 14283 typeMap.resize(region_num_rpos);
23325 14283 customTypeMap.resize(region_num_rpos);
23326 14283 istrig.resize(region_num_rpos);
23327
23328 //Store each different tile/color as grids
23329 14283 std::map<int32_t, spot_t*> maps;
23330 14283 std::map<int32_t, std::map<dword, spot_t>> ffmaps;
23331
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 int32_t shieldid = getCurrentShield(false);
23332
2/8
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14283 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14283 if((itemsbuf[shieldid].flags & item_flag9) && !usingActiveShield(shieldid))
23333 shieldid = -1;
23334
2/2
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
14283 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & sh_lightbeam);
23335
3/4
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
✓ Branch 2 taken 3391 times.
✗ Branch 3 not taken.
14283 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & sh_lightbeam);
23336
3/6
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14283 times.
✗ Branch 5 not taken.
14283 beam_hero_rpos = COMBOPOS_REGION_B(x.getInt()+8, y.getInt()+8);
23337
23338
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 clear_bitmap(lightbeam_bmp);
23339
23340 14283 bool foundany = false;
23341
23342
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
28566 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
23343 14283 bool pos_has_seen_cmb[176] = {0};
23344
23345
2/2
✓ Branch 0 taken 99981 times.
✓ Branch 1 taken 14283 times.
114264 for(int32_t lyr = 6; lyr >= 0; --lyr)
23346 {
23347 99981 mapscr* layer_scr = get_scr_layer(scr->screen, lyr);
23348
2/2
✓ Branch 0 taken 17596656 times.
✓ Branch 1 taken 99981 times.
17696637 for(size_t pos = 0; pos < 176; ++pos)
23349 {
23350
2/2
✓ Branch 0 taken 3723 times.
✓ Branch 1 taken 17592933 times.
17596656 if (pos_has_seen_cmb[pos])
23351 3723 continue;
23352
23353 17592933 rpos_t rpos = POS_TO_RPOS(pos, region_scr_x, region_scr_y);
23354 17592933 auto& cmb = combobuf[layer_scr->data[pos]];
23355
4/5
✓ Branch 0 taken 175417 times.
✓ Branch 1 taken 17399531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3702 times.
✓ Branch 4 taken 14283 times.
17592933 switch(cmb.type)
23356 {
23357 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
23358 case cMAGICPRISM: case cMAGICPRISM4:
23359 case cBLOCKALL: case cLIGHTTARGET:
23360 175417 typeMap[(int)rpos] = cmb.type;
23361 175417 break;
23362 case cMIRRORNEW:
23363 typeMap[(int)rpos] = cMIRRORNEW;
23364 customTypeMap[(int)rpos] = layer_scr->data[pos];
23365 break;
23366 case cGLASS:
23367 // Already been initialized to zero.
23368 3702 break;
23369 case cSPOTLIGHT:
23370 14283 foundany = true;
23371 [[fallthrough]];
23372 default:
23373 {
23374
4/4
✓ Branch 0 taken 7358582 times.
✓ Branch 1 taken 10055232 times.
✓ Branch 2 taken 6017045 times.
✓ Branch 3 taken 1341537 times.
17413814 if(lyr < 3 && (cmb.walk & 0xF))
23375 {
23376 1341537 typeMap[(int)rpos] = SPTYPE_SOLID;
23377 1341537 }
23378 17413814 continue; // may update on the next layer
23379 }
23380 }
23381
23382 179119 pos_has_seen_cmb[pos] = true;
23383 179119 }
23384 99981 }
23385
23386
2/2
✓ Branch 0 taken 2513808 times.
✓ Branch 1 taken 14283 times.
2528091 for (int pos = 0; pos < 176; pos++)
23387 {
23388 2513808 rpos_t rpos = POS_TO_RPOS(pos, region_scr_x, region_scr_y);
23389
4/4
✓ Branch 0 taken 2296624 times.
✓ Branch 1 taken 217184 times.
✓ Branch 2 taken 1421859 times.
✓ Branch 3 taken 874765 times.
2513808 if (!get_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ) && !typeMap[(int)rpos])
23390 {
23391 1749530 auto [x, y] = COMBOXY_REGION(rpos);
23392
2/4
✓ Branch 0 taken 874765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 874765 times.
✗ Branch 3 not taken.
1749530 if (collide_object(x, y, 16, 16, this))
23393 typeMap[(int)rpos] = SPTYPE_SOLID;
23394 874765 }
23395 2513808 }
23396 14283 });
23397
23398 // The world is dark and full of terrors.
23399
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if (!foundany) return;
23400
23401
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14031 times.
14283 switch (typeMap[(int)beam_hero_rpos])
23402 {
23403 case SPTYPE_SOLID: case cBLOCKALL:
23404 252 beam_hero_rpos = rpos_t::None; //Blocked from hitting player
23405 252 }
23406
23407
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
5721435 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
23408
2/2
✓ Branch 0 taken 5692869 times.
✓ Branch 1 taken 14283 times.
5707152 if (rpos_handle.ctype() == cSPOTLIGHT)
23409 14283 launch_lightbeam(rpos_handle, maps, refl, block);
23410 5707152 });
23411
23412
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
17985 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
23413 3702 ffcdata& ffc = *ffc_handle.ffc;
23414
1/2
✓ Branch 0 taken 3702 times.
✗ Branch 1 not taken.
3702 if (ffc.flags & (ffc_changer|ffc_ethereal))
23415 return;
23416
23417 3702 newcombo const& cmb = combobuf[ffc.data];
23418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3702 if (ffc_handle.ctype() == cSPOTLIGHT && (cmb.usrflags&cflag2))
23419 launch_fflightbeam(ffc,ffmaps,refl,block);
23420 3702 });
23421
23422
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 lightbeam_present = !maps.empty() || !ffmaps.empty();
23423
23424 //Draw visuals
23425
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14283 times.
28566 for(auto it = maps.begin(); it != maps.end();)
23426 {
23427 14283 int32_t id = it->first;
23428 14283 spot_t* grid = it->second;
23429
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 BITMAP* cbmp = generate_beam_bitmap(id);
23430
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 2499525 times.
2513808 for (rpos_t rpos = (rpos_t)0; rpos < region_max_rpos; rpos = (rpos_t)((int)rpos + 1))
23431 {
23432
1/2
✓ Branch 0 taken 2499525 times.
✗ Branch 1 not taken.
2499525 int32_t offs = get_beamoffs(grid[(int)rpos]);
23433
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 2422410 times.
2499525 if(offs > -1)
23434 {
23435
1/2
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
77115 auto [x, y] = COMBOXY_REGION(rpos);
23436
3/6
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77115 times.
✗ Branch 5 not taken.
231345 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, x-viewport.x, y-viewport.y, 16, 16);
23437 77115 }
23438 2499525 }
23439
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 destroy_bitmap(cbmp);
23440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 delete[] it->second;
23441
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 it = maps.erase(it);
23442 }
23443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 for(auto it = ffmaps.begin(); it != ffmaps.end();)
23444 {
23445 int32_t id = it->first;
23446 std::map<dword,spot_t> const& grid = it->second;
23447 BITMAP* cbmp = generate_beam_bitmap(id);
23448 for(auto it2 = grid.begin(); it2 != grid.end(); ++it2)
23449 {
23450 lightbeam_xy ffxy(it2->first);
23451 int32_t offs = get_beamoffs(it2->second);
23452 if(offs > -1)
23453 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, ffxy.x-8-viewport.x, ffxy.y-8-viewport.y, 16, 16);
23454 }
23455 destroy_bitmap(cbmp);
23456 it = ffmaps.erase(it);
23457 }
23458
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
14283 }
23459 else
23460 {
23461
2/2
✓ Branch 0 taken 14293170 times.
✓ Branch 1 taken 317 times.
14293487 if(had_spotlight)
23462 {
23463 317 istrig.clear();
23464 317 istrig.resize(region_num_rpos);
23465 317 clear_bitmap(lightbeam_bmp);
23466 317 }
23467 14293487 lightbeam_present = false;
23468 }
23469
23470 14307770 had_spotlight = lightbeam_present;
23471
23472 //Check triggers
23473 14307770 auto& combo_cache = combo_caches::spotlight;
23474 14307770 std::set<int> screens_triggered;
23475 14307770 bool istrigged = true;
23476
1/2
✓ Branch 0 taken 14307770 times.
✗ Branch 1 not taken.
5417105434 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
23477 5402797664 auto& mini_cmb = combo_cache.minis[rpos_handle.data()];
23478
2/2
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 5402784543 times.
5402797664 if (mini_cmb.target)
23479 {
23480 13121 auto& cmb = rpos_handle.combo();
23481 13121 bool alltrig = getmapflag(rpos_handle.scr, mLIGHTBEAM);
23482
2/2
✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 1234 times.
13121 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23483 13121 screens_triggered.insert(rpos_handle.screen);
23484 13121 bool trigged = (istrig[(int)rpos_handle.rpos]&trigflag);
23485
1/2
✓ Branch 0 taken 13121 times.
✗ Branch 1 not taken.
13121 if(cmb.usrflags&cflag2) //Invert
23486 trigged = !trigged;
23487
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 12872 times.
13121 if(cmb.usrflags&cflag1) //Solved Version
23488 {
23489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23490 {
23491 rpos_handle.decrement_data();
23492 istrigged = false;
23493 }
23494 249 }
23495 else //Unsolved version
23496 {
23497
3/4
✓ Branch 0 taken 12872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12868 times.
12872 if(alltrig || trigged) //Light
23498 4 rpos_handle.increment_data();
23499 12868 else istrigged = false;
23500 }
23501 13121 }
23502
2/2
✓ Branch 0 taken 5402780841 times.
✓ Branch 1 taken 3702 times.
5402784543 else if (mini_cmb.trigger)
23503 {
23504
1/2
✓ Branch 0 taken 3702 times.
✗ Branch 1 not taken.
7404 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
23505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = trig.triglbeam ? (1 << (trig.triglbeam-1)) : ~0;
23506 3702 bool trigged = (istrig[(int)rpos_handle.rpos]&trigflag);
23507 3702 return trig.trigger_flags.get(trigged ? TRIGFLAG_LIGHTON : TRIGFLAG_LIGHTOFF);
23508 });
23509 3702 }
23510 5402797664 });
23511
23512
1/2
✓ Branch 0 taken 14307770 times.
✗ Branch 1 not taken.
453813191 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
23513 439505421 ffcdata& ffc = *ffc_handle.ffc;
23514
2/2
✓ Branch 0 taken 438911956 times.
✓ Branch 1 taken 593465 times.
439505421 rpos_t rpos = get_qr(qr_BROKEN_LIGHTBEAM_HITBOX)
23515 438911956 ? COMBOPOS_REGION_B(ffc.x+8, ffc.y+8)
23516 593465 : COMBOPOS_REGION_B(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23517
2/2
✓ Branch 0 taken 309006 times.
✓ Branch 1 taken 439196415 times.
439505421 if (rpos == rpos_t::None)
23518 309006 return;
23519
23520 439196415 auto& mini_cmb = combo_cache.minis[ffc_handle.data()];
23521
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 439195181 times.
439196415 if (mini_cmb.target)
23522 {
23523 1234 auto& cmb = ffc_handle.combo();
23524 1234 bool alltrig = getmapflag(ffc_handle.scr, mLIGHTBEAM);
23525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23526 1234 screens_triggered.insert(ffc_handle.screen);
23527 1234 bool trigged = (istrig[(int)rpos]&trigflag);
23528
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb.usrflags&cflag2) //Invert
23529 trigged = !trigged;
23530
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb.usrflags&cflag1) //Solved Version
23531 {
23532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23533 {
23534 zc_ffc_modify(ffc, -1);
23535 istrigged = false;
23536 }
23537 249 }
23538 else //Unsolved version
23539 {
23540
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
23541 1 zc_ffc_modify(ffc, 1);
23542 984 else istrigged = false;
23543 }
23544 1234 }
23545 else //if (mini_cmb.trigger)
23546 {
23547
1/2
✓ Branch 0 taken 439195181 times.
✗ Branch 1 not taken.
439319882 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
23548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124701 times.
124701 int32_t trigflag = trig.triglbeam ? (1 << (trig.triglbeam-1)) : ~0;
23549 124701 bool trigged = (istrig[(int)rpos]&trigflag);
23550 124701 return trig.trigger_flags.get(trigged ? TRIGFLAG_LIGHTON : TRIGFLAG_LIGHTOFF);
23551 });
23552 }
23553 439505421 });
23554
23555 // Trigger secrets for every screen that has a light trigger.
23556
4/4
✓ Branch 0 taken 14294902 times.
✓ Branch 1 taken 12868 times.
✓ Branch 2 taken 14294649 times.
✓ Branch 3 taken 253 times.
14307770 if (istrigged && !screens_triggered.empty())
23557 {
23558
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 253 times.
506 for (int screen : screens_triggered)
23559 {
23560
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 mapscr* scr = get_scr(screen);
23561
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 bool alltrig = getmapflag(scr, mLIGHTBEAM);
23562
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 249 times.
253 if (alltrig)
23563 249 continue;
23564
23565
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 trigger_secrets_for_screen(TriggerSource::LightTrigger, screen, false);
23566
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 sfx(scr->secretsfx);
23567
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!(scr->flags5&fTEMPSECRETS))
23568 {
23569
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setmapflag(scr, mSECRET);
23570
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setmapflag(scr, mLIGHTBEAM);
23571 4 }
23572 }
23573 253 }
23574 14307770 }
23575
23576 14283254 void HeroClass::checktouchblk()
23577 {
23578
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268301 times.
14283254 if(toogam) return;
23579
23580
2/2
✓ Branch 0 taken 960681 times.
✓ Branch 1 taken 13307620 times.
14268301 if(!pushing)
23581 13307620 return;
23582
23583 960681 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
23584
23585
4/4
✓ Branch 0 taken 951905 times.
✓ Branch 1 taken 8776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 951809 times.
960681 if(charging > 0 || spins > 0) //if not I probably will at some point...
23586 {
23587
4/4
✓ Branch 0 taken 4072 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 1132 times.
8872 if(Up()&&Left())tdir = (charging%2)*2;
23588
4/4
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 1410 times.
✓ Branch 3 taken 1530 times.
7740 else if(Up()&&Right())tdir = (charging%2)*3;
23589
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 1681 times.
✓ Branch 3 taken 863 times.
6210 else if(Down()&&Left())tdir = 1+(charging%2)*1;
23590
4/4
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 869 times.
✓ Branch 3 taken 812 times.
5347 else if(Down()&&Right())tdir = 1+(charging%2)*2;
23591 else
23592 {
23593
2/2
✓ Branch 0 taken 1410 times.
✓ Branch 1 taken 3125 times.
4535 if(Up())tdir=0;
23594
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2261 times.
3125 else if(Down())tdir=1;
23595
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1382 times.
2261 else if(Left())tdir=2;
23596
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 else if(Right())tdir=3;
23597 }
23598 8872 }
23599
23600 960681 int32_t tx=0,ty=-1;
23601
23602
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 239559 times.
✓ Branch 2 taken 215738 times.
✓ Branch 3 taken 235775 times.
✓ Branch 4 taken 269609 times.
960681 switch(tdir)
23603 {
23604 case up:
23605
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 239338 times.
239559 if(touchcombo(x,y+(bigHitbox?0:7)))
23606 {
23607 221 tx=x;
23608 221 ty=y+(bigHitbox?0:7);
23609 221 }
23610
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 239313 times.
239338 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
23611 {
23612 25 tx=x+8;
23613 25 ty=y+(bigHitbox?0:7);
23614 25 }
23615
23616 239559 break;
23617
23618 case down:
23619
2/2
✓ Branch 0 taken 1673 times.
✓ Branch 1 taken 214065 times.
215738 if(touchcombo(x,y+16))
23620 {
23621 1673 tx=x;
23622 1673 ty=y+16;
23623 1673 }
23624
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 213801 times.
214065 else if(touchcombo(x+8,y+16))
23625 {
23626 264 tx=x+8;
23627 264 ty=y+16;
23628 264 }
23629
23630 215738 break;
23631
23632 case left:
23633
2/2
✓ Branch 0 taken 234934 times.
✓ Branch 1 taken 841 times.
235775 if(touchcombo(x-1,y+15))
23634 {
23635 841 tx=x-1;
23636 841 ty=y+15;
23637 841 }
23638
23639 235775 break;
23640
23641 case right:
23642
2/2
✓ Branch 0 taken 268427 times.
✓ Branch 1 taken 1182 times.
269609 if(touchcombo(x+16,y+15))
23643 {
23644 1182 tx=x+16;
23645 1182 ty=y+15;
23646 1182 }
23647
23648 269609 break;
23649 }
23650
23651
2/2
✓ Branch 0 taken 956475 times.
✓ Branch 1 taken 4206 times.
960681 if(ty>=0)
23652 {
23653
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4206 if (getAction() != hopping || isSideViewHero())
23654 {
23655 4206 trigger_armos_grave(get_rpos_handle_for_world_xy(tx, ty, 0), dir);
23656 4206 }
23657 4206 }
23658 14283254 }
23659
23660 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
23661 {
23662 switch(cdir)
23663 {
23664 case up:
23665 cy-=16;
23666 break;
23667
23668 case down:
23669 cy+=16;
23670 break;
23671
23672 case left:
23673 cx-=16;
23674 break;
23675
23676 case right:
23677 cx+=16;
23678 break;
23679 }
23680
23681 // off the screen
23682 if(cx<0 || cy<0 || cx>=world_w || cy>=world_h)
23683 {
23684 auto [map, screen] = nextscr2(cdir);
23685 if (map == -1)
23686 return 0;
23687
23688 switch(cdir)
23689 {
23690 case up:
23691 cy=160;
23692 break;
23693
23694 case down:
23695 cy=0;
23696 break;
23697
23698 case left:
23699 cx=240;
23700 break;
23701
23702 case right:
23703 cx=0;
23704 break;
23705 }
23706
23707 int32_t cmb = COMBOPOS(cx%256, cy%176);
23708 return get_canonical_scr(map, screen)->data[cmb];
23709 }
23710
23711 return MAPCOMBO(cx,cy);
23712 }
23713
23714 15867 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
23715 {
23716
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 3545 times.
✓ Branch 3 taken 3978 times.
✓ Branch 4 taken 5141 times.
15867 switch(cdir)
23717 {
23718 case up:
23719 3203 cy-=16;
23720 3203 break;
23721
23722 case down:
23723 3545 cy+=16;
23724 3545 break;
23725
23726 case left:
23727 3978 cx-=16;
23728 3978 break;
23729
23730 case right:
23731 5141 cx+=16;
23732 5141 break;
23733 }
23734
23735 // off the screen
23736
8/8
✓ Branch 0 taken 15766 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 15621 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 15447 times.
✓ Branch 5 taken 174 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 15255 times.
15867 if(cx<0 || cy<0 || cx>=world_w || cy>=world_h)
23737 {
23738 1828 auto [map, screen] = nextscr2(cdir);
23739
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 4 times.
612 if (map == -1)
23740 4 return 0;
23741
23742
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 174 times.
608 switch(cdir)
23743 {
23744 case up:
23745 143 cy=160;
23746 143 break;
23747
23748 case down:
23749 190 cy=0;
23750 190 break;
23751
23752 case left:
23753 101 cx=240;
23754 101 break;
23755
23756 case right:
23757 174 cx=0;
23758 174 break;
23759 }
23760
23761 608 int32_t pos = COMBOPOS(cx%256, cy%176);
23762 1216 const mapscr* scr = get_canonical_scr(map, screen);
23763
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 523 times.
608 if (!comboflag)
23764 {
23765 523 return scr->sflag[pos];
23766 }
23767 else
23768 {
23769 85 return combo_caches::flag.minis[scr->data[pos]].flag;
23770 }
23771 }
23772
23773
2/2
✓ Branch 0 taken 3952 times.
✓ Branch 1 taken 11303 times.
15255 if(comboflag)
23774 {
23775 3952 return MAPCOMBOFLAG(cx,cy);
23776 }
23777
23778 11303 return MAPFLAG(cx,cy);
23779 15867 }
23780
23781 14283254 void HeroClass::checkspecial()
23782 {
23783 14283254 checktouchblk();
23784
23785 28918930 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
23786 14635676 int screen = scr->screen;
23787 14635676 auto& state = get_screen_state(screen);
23788 14635676 bool hasmainguy = hasMainGuy(screen);
23789
4/4
✓ Branch 0 taken 14208476 times.
✓ Branch 1 taken 427200 times.
✓ Branch 2 taken 8558066 times.
✓ Branch 3 taken 5650410 times.
14635676 if (!state.loaded_enemies || hasmainguy)
23790 {
23791 8985266 state.did_enemy_secret = false;
23792 8985266 }
23793 else
23794 {
23795 // Enemies have been defeated.
23796
23797 // generic 'Enemies->' trigger
23798 2102219351 for_every_combo_in_screen(create_screen_handles(scr), [&](const auto& handle) {
23799
2/4
✓ Branch 0 taken 2094958272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1610669 times.
✗ Branch 3 not taken.
2183321154 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
23800 86752213 return trig.trigger_flags.get(TRIGFLAG_ENEMIESKILLED);
23801 });
23802 2096568941 });
23803
23804
1/2
✓ Branch 0 taken 5650410 times.
✗ Branch 1 not taken.
5650410 if (scr->flags9 & fENEMY_WAVES)
23805 {
23806 hasmainguy = hasMainGuy(screen); //possibly un-beat the enemies (another 'wave'?)
23807 }
23808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5650410 times.
5650410 if(!hasmainguy)
23809 {
23810 // item
23811
5/6
✓ Branch 0 taken 5650402 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5650402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 754 times.
✓ Branch 5 taken 5649648 times.
5650410 if (state.item_state == ScreenItemState::MustGiveToEnemy || state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::WhenKillEnemies)
23812 {
23813 762 int32_t Item=scr->item;
23814
23815
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
762 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
23816 {
23817
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 754 times.
762 if (state.item_state == ScreenItemState::WhenKillEnemies)
23818 754 sfx(WAV_CLEARED);
23819
23820 762 zfix x = region_scr_x*256 + scr->itemx;
23821
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 691 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
762 zfix y = region_scr_y*176 + ((scr->flags7&fITEMFALLS && isSideViewHero()) ? -170 : scr->itemy+1);
23822
9/16
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 71 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 71 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 71 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 691 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 762 times.
✗ Branch 15 not taken.
1524 add_item_for_screen(screen, new item(x, y, (scr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
23823
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 761 times.
762 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
23824 762 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
23825 762 }
23826
23827 762 state.item_state = ScreenItemState::None;
23828 762 }
23829 // if room has traps, guys don't come back
23830
2/2
✓ Branch 0 taken 2893009920 times.
✓ Branch 1 taken 5650410 times.
2898660330 for (int32_t i=0; i<eMAXGUYS; i++)
23831 {
23832
4/4
✓ Branch 0 taken 84280171 times.
✓ Branch 1 taken 2808729749 times.
✓ Branch 2 taken 11243614 times.
✓ Branch 3 taken 73036557 times.
2893009920 if (guysbuf[i].family==eeTRAP&&guysbuf[i].attributes[1])
23833
4/4
✓ Branch 0 taken 79095 times.
✓ Branch 1 taken 11164519 times.
✓ Branch 2 taken 78998 times.
✓ Branch 3 taken 97 times.
11243711 if (guys.idCount(i, screen) && !getmapflag(screen, mTMPNORET))
23834 97 setmapflag(scr, mTMPNORET);
23835 2893009920 }
23836 // clear enemies and open secret
23837
4/4
✓ Branch 0 taken 5458979 times.
✓ Branch 1 taken 191431 times.
✓ Branch 2 taken 5458123 times.
✓ Branch 3 taken 856 times.
5650410 if (!state.did_enemy_secret && (scr->flags2&fCLEARSECRET))
23838 {
23839 856 bool only16_31 = get_qr(qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
23840 856 trigger_secrets_for_screen(TriggerSource::EnemiesScreenFlag, scr, only16_31);
23841
23842
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 750 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 101 times.
856 if (scr->flags4&fENEMYSCRTPERM && canPermSecret(cur_dmap, screen))
23843 {
23844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (!(scr->flags5&fTEMPSECRETS)) setmapflag(scr, mSECRET);
23845 101 }
23846
23847 856 sfx(scr->secretsfx);
23848 856 state.did_enemy_secret = true;
23849 856 }
23850 5650410 }
23851 }
23852
23853 // doors
23854 14635676 bool has_shutter = false;
23855
23856
2/2
✓ Branch 0 taken 12603818 times.
✓ Branch 1 taken 54900482 times.
67504300 for (int i = 0; i < 4; i++)
23857 {
23858
2/2
✓ Branch 0 taken 52868624 times.
✓ Branch 1 taken 2031858 times.
54900482 if (scr->door[i]==dSHUTTER)
23859 {
23860 2031858 has_shutter = true;
23861
4/4
✓ Branch 0 taken 1991600 times.
✓ Branch 1 taken 40258 times.
✓ Branch 2 taken 1424 times.
✓ Branch 3 taken 1990176 times.
2031858 if (state.open_doors == 0 && state.loaded_enemies)
23862 {
23863
4/4
✓ Branch 0 taken 1657895 times.
✓ Branch 1 taken 332281 times.
✓ Branch 2 taken 1655472 times.
✓ Branch 3 taken 2423 times.
1990176 if (!(scr->flags&fSHUTTERS) && !hasmainguy)
23864 2423 state.open_doors=12;
23865 1990176 }
23866
2/2
✓ Branch 0 taken 32960 times.
✓ Branch 1 taken 8722 times.
41682 else if (state.open_doors < 0)
23867 8722 ++state.open_doors;
23868
2/2
✓ Branch 0 taken 30229 times.
✓ Branch 1 taken 2731 times.
32960 else if (--state.open_doors == 0)
23869 2731 openshutters(scr);
23870
23871 2031858 break;
23872 }
23873 52868624 }
23874
23875
10/10
✓ Branch 0 taken 12603818 times.
✓ Branch 1 taken 2031858 times.
✓ Branch 2 taken 12450577 times.
✓ Branch 3 taken 153241 times.
✓ Branch 4 taken 12030233 times.
✓ Branch 5 taken 420344 times.
✓ Branch 6 taken 11957713 times.
✓ Branch 7 taken 72520 times.
✓ Branch 8 taken 6603073 times.
✓ Branch 9 taken 5354640 times.
14635676 if (!has_shutter && !state.open_doors && state.loaded_enemies && !(scr->flags&fSHUTTERS) && !hasmainguy)
23876 {
23877 5354640 openshutters(scr);
23878 5354640 }
23879
23880 // set boss flag when boss is gone
23881
6/6
✓ Branch 0 taken 14208476 times.
✓ Branch 1 taken 427200 times.
✓ Branch 2 taken 204006 times.
✓ Branch 3 taken 14004470 times.
✓ Branch 4 taken 153974 times.
✓ Branch 5 taken 50032 times.
14635676 if (state.loaded_enemies && scr->flags11&efBOSS && !hasmainguy)
23882 {
23883 50032 game->lvlitems[dlevel]|=liBOSS;
23884 50032 stop_sfx(scr->bosssfx);
23885 50032 }
23886
23887 14635676 auto screen_handles = create_screen_handles(scr);
23888
23889
2/2
✓ Branch 0 taken 14559380 times.
✓ Branch 1 taken 76296 times.
14635676 if (getmapflag(screen, mCHEST)) // if special stuff done before
23890 {
23891 76296 remove_chests(screen_handles);
23892 76296 }
23893
23894
2/2
✓ Branch 0 taken 14633216 times.
✓ Branch 1 taken 2460 times.
14635676 if(getmapflag(screen, mLOCKEDCHEST)) // if special stuff done before
23895 {
23896 2460 remove_lockedchests(screen_handles);
23897 2460 }
23898
23899
2/2
✓ Branch 0 taken 14609475 times.
✓ Branch 1 taken 26201 times.
14635676 if(getmapflag(screen, mBOSSCHEST)) // if special stuff done before
23900 {
23901 26201 remove_bosschests(screen_handles);
23902 26201 }
23903
23904 14635676 clear_xdoors(screen_handles, true);
23905 14635676 clear_xstatecombos(screen_handles, true);
23906
23907
4/4
✓ Branch 0 taken 1375120 times.
✓ Branch 1 taken 13260556 times.
✓ Branch 2 taken 1375094 times.
✓ Branch 3 taken 26 times.
14635676 if (state.triggered_secrets && state.item_state == ScreenItemState::WhenTriggerSecrets)
23908 {
23909 26 int32_t Item=scr->item;
23910
23911
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 24 times.
26 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
23912 {
23913
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
24 auto [x, y] = translate_screen_coordinates_to_world(screen, scr->itemx, (scr->flags7&fITEMFALLS && isSideViewHero()) ? -170 : scr->itemy+1);
23914
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
72 add_item_for_screen(screen, new item(x, y,
23915
6/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
24 (scr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
23916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
23917 24 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
23918 24 }
23919
23920 26 state.item_state = ScreenItemState::None;
23921 26 }
23922 14635676 });
23923 14283254 }
23924
23925 // Returns 4 rpos indicated by all combinations of the coordinates, replacing duplicates with rpos_t::None
23926 13656240 static std::array<rpos_t, 4> getRposes(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
23927 {
23928 std::array<rpos_t, 4> rposes;
23929 rpos_t tmp;
23930
23931 13656240 rposes[0] = COMBOPOS_REGION_B(x1,y1);
23932
23933 13656240 tmp = COMBOPOS_REGION_B(x1,y2);
23934
2/2
✓ Branch 0 taken 9877955 times.
✓ Branch 1 taken 3778285 times.
13656240 if (tmp == rposes[0])
23935 9877955 rposes[1] = rpos_t::None;
23936 3778285 else rposes[1] = tmp;
23937
23938 13656240 tmp = COMBOPOS_REGION_B(x2,y1);
23939
3/4
✓ Branch 0 taken 6634781 times.
✓ Branch 1 taken 7021459 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6634781 times.
13656240 if (tmp == rposes[0] || tmp == rposes[1])
23940 7021459 rposes[2] = rpos_t::None;
23941 6634781 else rposes[2] = tmp;
23942
23943 13656240 tmp = COMBOPOS_REGION_B(x2,y2);
23944
6/6
✓ Branch 0 taken 8605500 times.
✓ Branch 1 taken 5050740 times.
✓ Branch 2 taken 6634781 times.
✓ Branch 3 taken 1970719 times.
✓ Branch 4 taken 4827215 times.
✓ Branch 5 taken 1807566 times.
13656240 if (tmp == rposes[0] || tmp == rposes[1] || tmp == rposes[2])
23945 11848674 rposes[3] = rpos_t::None;
23946 1807566 else rposes[3] = tmp;
23947
23948 13656240 return rposes;
23949 }
23950
23951 14235856 void HeroClass::checkspecial2(int32_t *ls)
23952 {
23953
6/8
✓ Branch 0 taken 9981839 times.
✓ Branch 1 taken 4254017 times.
✓ Branch 2 taken 9717786 times.
✓ Branch 3 taken 264053 times.
✓ Branch 4 taken 9717786 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9717786 times.
14235856 if(get_qr(qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
23954 {
23955 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
23956
2/2
✓ Branch 0 taken 21923 times.
✓ Branch 1 taken 9695863 times.
9717786 if (!fairyclk)
23957 {
23958
2/2
✓ Branch 0 taken 2922314 times.
✓ Branch 1 taken 6773549 times.
9695863 if(y.getInt()&7)
23959 2922314 return;
23960
23961
2/2
✓ Branch 0 taken 3818491 times.
✓ Branch 1 taken 2955058 times.
6773549 if(x.getInt()&7)
23962 3818491 return;
23963 2955058 }
23964 2976981 }
23965
23966
2/2
✓ Branch 0 taken 6059 times.
✓ Branch 1 taken 7488992 times.
7495051 if(toogam) return;
23967
23968 7488992 bool didstrig = false;
23969
23970
2/2
✓ Branch 0 taken 14977950 times.
✓ Branch 1 taken 7488952 times.
22466902 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
23971 {
23972
4/4
✓ Branch 0 taken 29955871 times.
✓ Branch 1 taken 14977910 times.
✓ Branch 2 taken 59911702 times.
✓ Branch 3 taken 29955831 times.
104845443 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
23973 {
23974 59911702 int comboid = 0;
23975 mapscr* scr;
23976
2/2
✓ Branch 0 taken 29955831 times.
✓ Branch 1 taken 29955871 times.
59911702 if (k > 0)
23977 {
23978 29955831 auto ffc_handle = getFFCAt(x+j, y+i);
23979
2/2
✓ Branch 0 taken 29452301 times.
✓ Branch 1 taken 503530 times.
29955831 if (ffc_handle)
23980 {
23981 503530 comboid = ffc_handle->data();
23982 503530 scr = ffc_handle->scr;
23983 503530 }
23984 29955831 }
23985 else
23986 {
23987 29955871 auto rpos_handle = get_rpos_handle_for_world_xy(x+j, y+i, 0);
23988 29955871 comboid = rpos_handle.data();
23989 29955871 scr = rpos_handle.scr;
23990 }
23991 59911702 newcombo const& cmb = combobuf[comboid];
23992 59911702 int32_t stype = cmb.type;
23993 59911702 int32_t warpsound = cmb.attribytes[0];
23994
2/2
✓ Branch 0 taken 59911500 times.
✓ Branch 1 taken 202 times.
59911702 if(cmb.only_gentrig)
23995 202 stype = cNONE;
23996
2/2
✓ Branch 0 taken 59911668 times.
✓ Branch 1 taken 34 times.
59911702 if(stype==cSWARPA)
23997 {
23998
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
34 if(scr->flags5&fDIRECTSWARP)
23999 {
24000 1 setpit();
24001 1 }
24002
24003 34 sdir=dir;
24004 34 dowarp(scr,0,0,warpsound);
24005 34 return;
24006 }
24007
24008
2/2
✓ Branch 0 taken 59911663 times.
✓ Branch 1 taken 5 times.
59911668 if(stype==cSWARPB)
24009 {
24010
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scr->flags5&fDIRECTSWARP)
24011 {
24012 setpit();
24013 }
24014
24015 5 sdir=dir;
24016 5 dowarp(scr,0,1,warpsound);
24017 5 return;
24018 }
24019
24020
2/2
✓ Branch 0 taken 59911662 times.
✓ Branch 1 taken 1 times.
59911663 if(stype==cSWARPC)
24021 {
24022
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(scr->flags5&fDIRECTSWARP)
24023 {
24024 setpit();
24025 }
24026
24027 1 sdir=dir;
24028 1 dowarp(scr,0,2,warpsound);
24029 1 return;
24030 }
24031
24032
1/2
✓ Branch 0 taken 59911662 times.
✗ Branch 1 not taken.
59911662 if(stype==cSWARPD)
24033 {
24034 if(scr->flags5&fDIRECTSWARP)
24035 {
24036 setpit();
24037 }
24038
24039 sdir=dir;
24040 dowarp(scr,0,3,warpsound);
24041 return;
24042 }
24043
24044
1/2
✓ Branch 0 taken 59911662 times.
✗ Branch 1 not taken.
59911662 if(stype==cSWARPR)
24045 {
24046 if(scr->flags5&fDIRECTSWARP)
24047 {
24048 setpit();
24049 }
24050
24051 sdir=dir;
24052 dowarp(scr,0,(zc_oldrand()%4),warpsound);
24053 return;
24054 }
24055
24056 59911662 rpos_t rpos = COMBOPOS_REGION(x+j, y+i);
24057
4/4
✓ Branch 0 taken 59907512 times.
✓ Branch 1 taken 4150 times.
✓ Branch 2 taken 59909183 times.
✓ Branch 3 taken 2479 times.
59911662 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=rpos)
24058 {
24059 2479 auto rpos_handle = get_rpos_handle(rpos, 0);
24060
24061
3/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 895 times.
2479 if(stype==cSTRIGFLAG && canPermSecret(cur_dmap, rpos_handle.screen))
24062 {
24063
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 603 times.
895 if(!didstrig)
24064 {
24065 603 stepsecret = rpos;
24066
24067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(!(rpos_handle.scr->flags5&fTEMPSECRETS))
24068 {
24069 603 setmapflag(rpos_handle.scr, mSECRET);
24070 603 }
24071 603 sfx(warpsound,pan((int32_t)x));
24072 603 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), false);
24073 603 didstrig = true;
24074 603 }
24075 895 }
24076 else
24077 {
24078
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 904 times.
1584 if(!didstrig)
24079 {
24080 904 stepsecret = rpos;
24081
24082 904 bool high16only = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24083 904 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), high16only);
24084 904 didstrig = true;
24085 904 sfx(warpsound,pan((int32_t)x));
24086 904 }
24087 }
24088 2479 }
24089 89867493 }
24090 14977910 }
24091
24092 7488952 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
24093
24094 // check if he's standing on a warp he just came out of
24095 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
24096
2/2
✓ Branch 0 taken 2008545 times.
✓ Branch 1 taken 5480407 times.
7488952 if (!get_qr(qr_210_WARPRETURN))
24097 {
24098
6/6
✓ Branch 0 taken 5478433 times.
✓ Branch 1 taken 1974 times.
✓ Branch 2 taken 359238 times.
✓ Branch 3 taken 5119195 times.
✓ Branch 4 taken 55319 times.
✓ Branch 5 taken 303919 times.
5480407 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
24099 {
24100
5/6
✓ Branch 0 taken 302855 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 301356 times.
✓ Branch 3 taken 1499 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 301356 times.
303919 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
24101 {
24102
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 301351 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
301356 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24103 301356 else return;
24104 }
24105 2563 }
24106 5179051 }
24107 else
24108 {
24109
2/2
✓ Branch 0 taken 1677137 times.
✓ Branch 1 taken 331408 times.
2008545 if(TRUNCATE_HALF_TILE(int32_t(y))==warpy)
24110 {
24111
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 327332 times.
331408 if(x==warpx)
24112 {
24113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327332 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24114 327332 else return;
24115 }
24116 4076 }
24117 }
24118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6860264 times.
6860264 if (!RaftPass) warpy=-1;
24119
24120
6/6
✓ Branch 0 taken 6852858 times.
✓ Branch 1 taken 7406 times.
✓ Branch 2 taken 324324 times.
✓ Branch 3 taken 6528534 times.
✓ Branch 4 taken 238314 times.
✓ Branch 5 taken 86010 times.
6860264 if(((int32_t)y<raftwarpy-(get_qr(qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_qr(qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
24121 {
24122 6621950 raftwarpy = -1;
24123 6621950 }
24124
6/6
✓ Branch 0 taken 6854210 times.
✓ Branch 1 taken 6054 times.
✓ Branch 2 taken 314810 times.
✓ Branch 3 taken 6539400 times.
✓ Branch 4 taken 239696 times.
✓ Branch 5 taken 75114 times.
6860264 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
24125 {
24126 6620568 raftwarpx = -1;
24127 6620568 }
24128 6860264 int32_t tx=x;
24129 6860264 int32_t ty=y;
24130
24131 6860264 int32_t flag=0;
24132 6860264 int32_t flag2=0;
24133 6860264 int32_t flag3=0;
24134 6860264 mapscr* flag_scr=nullptr;
24135 6860264 mapscr* flag2_scr=nullptr;
24136 6860264 mapscr* flag3_scr=nullptr;
24137 6860264 mapscr* scrs[4]={};
24138 6860264 rpos_handle_t rpos_handles[4];
24139 6860264 int32_t type=0;
24140 6860264 int32_t water=0;
24141 6860264 int32_t index = 0;
24142
24143 6860264 bool setsave=false;
24144 6860264 int32_t warpsfx2 = 0;
24145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6860264 times.
6860264 if (RaftPass) goto RaftingStuff;
24146
24147 int32_t x1,x2,y1,y2;
24148 6860264 x1 = tx;
24149 6860264 x2 = tx+15;
24150 6860264 y1 = ty;
24151 6860264 y2 = ty+15;
24152
24153
4/6
✓ Branch 0 taken 2514335 times.
✓ Branch 1 taken 4345929 times.
✓ Branch 2 taken 2514335 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2514335 times.
6860264 if((diagonalMovement||NO_GRIDLOCK))
24154 {
24155 4345929 x1 = tx+4;
24156 4345929 x2 = tx+11;
24157 4345929 y1 = ty+4;
24158 4345929 y2 = ty+11;
24159 4345929 }
24160
24161 int32_t types[4];
24162 6860264 types[0]=types[1]=types[2]=types[3]=-1;
24163 int32_t cids[4];
24164 int32_t ffcids[4];
24165 6860264 cids[0]=cids[1]=cids[2]=cids[3]=-1;
24166 6860264 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
24167 //
24168 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
24169 //
24170
24171 6860264 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
24172 6860264 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
24173 6860264 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
24174 6860264 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
24175
24176 6860264 types[0] = rpos_handles[0].sflag();
24177 6860264 types[1] = rpos_handles[1].sflag();
24178 6860264 types[2] = rpos_handles[2].sflag();
24179 6860264 types[3] = rpos_handles[3].sflag();
24180
24181 6860264 flag_scr = rpos_handles[0].scr;
24182
24183 //MAPFFCOMBO
24184
24185
6/6
✓ Branch 0 taken 6639388 times.
✓ Branch 1 taken 220876 times.
✓ Branch 2 taken 6611900 times.
✓ Branch 3 taken 27488 times.
✓ Branch 4 taken 85235 times.
✓ Branch 5 taken 6526665 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24186 6526665 flag = types[0];
24187 // 2.10 compatibility...
24188
10/10
✓ Branch 0 taken 148449 times.
✓ Branch 1 taken 185150 times.
✓ Branch 2 taken 122271 times.
✓ Branch 3 taken 26178 times.
✓ Branch 4 taken 108406 times.
✓ Branch 5 taken 13865 times.
✓ Branch 6 taken 108310 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 108212 times.
333599 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24189 14059 flag = types[0];
24190
24191
24192 6860264 types[0] = rpos_handles[0].cflag();
24193 6860264 types[1] = rpos_handles[1].cflag();
24194 6860264 types[2] = rpos_handles[2].cflag();
24195 6860264 types[3] = rpos_handles[3].cflag();
24196 6860264 flag2_scr = rpos_handles[0].scr;
24197
24198
6/6
✓ Branch 0 taken 6799312 times.
✓ Branch 1 taken 60952 times.
✓ Branch 2 taken 6792249 times.
✓ Branch 3 taken 7063 times.
✓ Branch 4 taken 17768 times.
✓ Branch 5 taken 6774481 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24199 6774481 flag2 = types[0];
24200
9/12
✓ Branch 0 taken 20949 times.
✓ Branch 1 taken 64834 times.
✓ Branch 2 taken 3350 times.
✓ Branch 3 taken 17599 times.
✓ Branch 4 taken 2740 times.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 2740 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2740 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2740 times.
85783 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24201 flag2 = types[0];
24202
24203 {
24204 6860264 auto ffc_handle_1 = getFFCAt(x1, y1);
24205 6860264 auto ffc_handle_2 = getFFCAt(x1, y2);
24206 6860264 auto ffc_handle_3 = getFFCAt(x2, y1);
24207 6860264 auto ffc_handle_4 = getFFCAt(x2, y2);
24208
24209
2/2
✓ Branch 0 taken 174885 times.
✓ Branch 1 taken 6685379 times.
6860264 types[0] = ffc_handle_1 ? ffc_handle_1->cflag() : 0;
24210
2/2
✓ Branch 0 taken 129891 times.
✓ Branch 1 taken 6730373 times.
6860264 types[1] = ffc_handle_2 ? ffc_handle_2->cflag() : 0;
24211
2/2
✓ Branch 0 taken 174314 times.
✓ Branch 1 taken 6685950 times.
6860264 types[2] = ffc_handle_3 ? ffc_handle_3->cflag() : 0;
24212
2/2
✓ Branch 0 taken 130473 times.
✓ Branch 1 taken 6729791 times.
6860264 types[3] = ffc_handle_4 ? ffc_handle_4->cflag() : 0;
24213
24214
2/2
✓ Branch 0 taken 174885 times.
✓ Branch 1 taken 6685379 times.
6860264 if (ffc_handle_1)
24215 174885 flag3_scr = ffc_handle_1->scr;
24216
2/2
✓ Branch 0 taken 21249 times.
✓ Branch 1 taken 6664130 times.
6685379 else if (ffc_handle_2)
24217 21249 flag3_scr = ffc_handle_2->scr;
24218
2/2
✓ Branch 0 taken 18021 times.
✓ Branch 1 taken 6646109 times.
6664130 else if (ffc_handle_3)
24219 18021 flag3_scr = ffc_handle_3->scr;
24220
2/2
✓ Branch 0 taken 6641239 times.
✓ Branch 1 taken 4870 times.
6646109 else if (ffc_handle_4)
24221 4870 flag3_scr = ffc_handle_4->scr;
24222 }
24223
24224 //
24225
24226
6/6
✓ Branch 0 taken 6859663 times.
✓ Branch 1 taken 601 times.
✓ Branch 2 taken 6859516 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 6859501 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24227 6859501 flag3 = types[0];
24228
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
763 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24229 flag3 = types[0];
24230
24231 //
24232 // Now, let's check for warp combos...
24233 //
24234
24235 //
24236
24237 6860264 cids[0] = rpos_handles[0].data();
24238 6860264 cids[1] = rpos_handles[1].data();
24239 6860264 cids[2] = rpos_handles[2].data();
24240 6860264 cids[3] = rpos_handles[3].data();
24241
24242 6860264 types[0] = rpos_handles[0].ctype();
24243
2/2
✓ Branch 0 taken 6685379 times.
✓ Branch 1 taken 174885 times.
6860264 if (auto ffc_handle = getFFCAt(x1, y1))
24244 {
24245 174885 types[0] = ffc_handle->ctype();
24246 174885 cids[0] = ffc_handle->data();
24247 174885 }
24248
24249 6860264 types[1] = rpos_handles[1].ctype();
24250
2/2
✓ Branch 0 taken 6730373 times.
✓ Branch 1 taken 129891 times.
6860264 if (auto ffc_handle = getFFCAt(x1, y2))
24251 {
24252 129891 types[1] = ffc_handle->ctype();
24253 129891 cids[1] = ffc_handle->data();
24254 129891 }
24255
24256 6860264 types[2] = rpos_handles[2].ctype();
24257
2/2
✓ Branch 0 taken 6685950 times.
✓ Branch 1 taken 174314 times.
6860264 if (auto ffc_handle = getFFCAt(x2, y1))
24258 {
24259 174314 types[2] = ffc_handle->ctype();
24260 174314 cids[2] = ffc_handle->data();
24261 174314 }
24262
24263 6860264 types[3] = rpos_handles[3].ctype();
24264
2/2
✓ Branch 0 taken 6729791 times.
✓ Branch 1 taken 130473 times.
6860264 if (auto ffc_handle = getFFCAt(x2, y2))
24265 {
24266 130473 types[3] = ffc_handle->ctype();
24267 130473 cids[3] = ffc_handle->data();
24268 130473 }
24269
24270 // Change B, C and D warps into A, for the comparison below...
24271
2/2
✓ Branch 0 taken 27441056 times.
✓ Branch 1 taken 6860264 times.
34301320 for(int32_t i=0; i<4; i++)
24272 {
24273
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 27440732 times.
27441056 if(combobuf[cids[i]].only_gentrig)
24274 {
24275 324 types[i] = cNONE;
24276 324 continue;
24277 }
24278
2/2
✓ Branch 0 taken 6937 times.
✓ Branch 1 taken 27433795 times.
27440732 if(types[i]==cCAVE)
24279 {
24280 6937 index=0;
24281 6937 warpsfx2 = combobuf[cids[i]].attribytes[0];
24282 6937 }
24283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27433795 times.
27433795 else if(types[i]==cCAVEB)
24284 {
24285 types[i]=cCAVE;
24286 index=1;
24287 warpsfx2 = combobuf[cids[i]].attribytes[0];
24288 }
24289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27433795 times.
27433795 else if(types[i]==cCAVEC)
24290 {
24291 types[i]=cCAVE;
24292 index=2;
24293 warpsfx2 = combobuf[cids[i]].attribytes[0];
24294 }
24295
1/2
✓ Branch 0 taken 27433795 times.
✗ Branch 1 not taken.
27433795 else if(types[i]==cCAVED)
24296 {
24297 types[i]=cCAVE;
24298 index=3;
24299 warpsfx2 = combobuf[cids[i]].attribytes[0];
24300 }
24301
24302
2/2
✓ Branch 0 taken 9519 times.
✓ Branch 1 taken 27431213 times.
27440732 if(types[i]==cPIT)
24303 {
24304 9519 index=0;
24305 9519 warpsfx2 = combobuf[cids[i]].attribytes[0];
24306 9519 }
24307
2/2
✓ Branch 0 taken 5708 times.
✓ Branch 1 taken 27425505 times.
27431213 else if(types[i]==cPITB)
24308 {
24309 5708 types[i]=cPIT;
24310 5708 warpsfx2 = combobuf[cids[i]].attribytes[0];
24311 5708 index=1;
24312 5708 }
24313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27425505 times.
27425505 else if(types[i]==cPITC)
24314 {
24315 types[i]=cPIT;
24316 warpsfx2 = combobuf[cids[i]].attribytes[0];
24317 index=2;
24318 }
24319
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 27425499 times.
27425505 else if(types[i]==cPITD)
24320 {
24321 6 types[i]=cPIT;
24322 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
24323 6 index=3;
24324 6 }
24325
1/2
✓ Branch 0 taken 27425499 times.
✗ Branch 1 not taken.
27425499 else if(types[i]==cPITR)
24326 {
24327 types[i]=cPIT;
24328 warpsfx2 = combobuf[cids[i]].attribytes[0];
24329 index=zc_oldrand()%4;
24330 }
24331
24332
2/2
✓ Branch 0 taken 32729 times.
✓ Branch 1 taken 27408003 times.
27440732 if(types[i]==cSTAIR)
24333 {
24334 32729 index=0;
24335 32729 warpsfx2 = combobuf[cids[i]].attribytes[0];
24336 32729 }
24337
2/2
✓ Branch 0 taken 1685 times.
✓ Branch 1 taken 27406318 times.
27408003 else if(types[i]==cSTAIRB)
24338 {
24339 1685 types[i]=cSTAIR;
24340 1685 warpsfx2 = combobuf[cids[i]].attribytes[0];
24341 1685 index=1;
24342 1685 }
24343
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 27406200 times.
27406318 else if(types[i]==cSTAIRC)
24344 {
24345 118 types[i]=cSTAIR;
24346 118 warpsfx2 = combobuf[cids[i]].attribytes[0];
24347 118 index=2;
24348 118 }
24349
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 27405997 times.
27406200 else if(types[i]==cSTAIRD)
24350 {
24351 203 types[i]=cSTAIR;
24352 203 warpsfx2 = combobuf[cids[i]].attribytes[0];
24353 203 index=3;
24354 203 }
24355
1/2
✓ Branch 0 taken 27405997 times.
✗ Branch 1 not taken.
27405997 else if(types[i]==cSTAIRR)
24356 {
24357 types[i]=cSTAIR;
24358 index=zc_oldrand()%4;
24359 warpsfx2 = combobuf[cids[i]].attribytes[0];
24360 }
24361
24362
2/2
✓ Branch 0 taken 6587 times.
✓ Branch 1 taken 27434145 times.
27440732 if(types[i]==cCAVE2)
24363 {
24364 6587 index=0;
24365 6587 warpsfx2 = combobuf[cids[i]].attribytes[0];
24366 6587 }
24367
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 27433812 times.
27434145 else if(types[i]==cCAVE2B)
24368 {
24369 333 types[i]=cCAVE2;
24370 333 index=1;
24371 333 warpsfx2 = combobuf[cids[i]].attribytes[0];
24372 333 }
24373
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 27433649 times.
27433812 else if(types[i]==cCAVE2C)
24374 {
24375 163 types[i]=cCAVE2;
24376 163 warpsfx2 = combobuf[cids[i]].attribytes[0];
24377 163 index=2;
24378 163 }
24379
1/2
✓ Branch 0 taken 27433649 times.
✗ Branch 1 not taken.
27433649 else if(types[i]==cCAVE2D)
24380 {
24381 types[i]=cCAVE2;
24382 warpsfx2 = combobuf[cids[i]].attribytes[0];
24383 index=3;
24384 }
24385
24386
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 27440577 times.
27440732 if(types[i]==cSWIMWARP)
24387 {
24388 155 index=0;
24389 155 warpsfx2 = combobuf[cids[i]].attribytes[0];
24390 155 }
24391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440577 times.
27440577 else if(types[i]==cSWIMWARPB)
24392 {
24393 types[i]=cSWIMWARP;
24394 warpsfx2 = combobuf[cids[i]].attribytes[0];
24395 index=1;
24396 }
24397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440577 times.
27440577 else if(types[i]==cSWIMWARPC)
24398 {
24399 types[i]=cSWIMWARP;
24400 warpsfx2 = combobuf[cids[i]].attribytes[0];
24401 index=2;
24402 }
24403
1/2
✓ Branch 0 taken 27440577 times.
✗ Branch 1 not taken.
27440577 else if(types[i]==cSWIMWARPD)
24404 {
24405 types[i]=cSWIMWARP;
24406 warpsfx2 = combobuf[cids[i]].attribytes[0];
24407 index=3;
24408 }
24409
24410
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 27440137 times.
27440732 if(types[i]==cDIVEWARP)
24411 {
24412 595 index=0;
24413 595 warpsfx2 = combobuf[cids[i]].attribytes[0];
24414 595 }
24415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440137 times.
27440137 else if(types[i]==cDIVEWARPB)
24416 {
24417 types[i]=cDIVEWARP;
24418 warpsfx2 = combobuf[cids[i]].attribytes[0];
24419 index=1;
24420 }
24421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440137 times.
27440137 else if(types[i]==cDIVEWARPC)
24422 {
24423 types[i]=cDIVEWARP;
24424 warpsfx2 = combobuf[cids[i]].attribytes[0];
24425 index=2;
24426 }
24427
1/2
✓ Branch 0 taken 27440137 times.
✗ Branch 1 not taken.
27440137 else if(types[i]==cDIVEWARPD)
24428 {
24429 types[i]=cDIVEWARP;
24430 warpsfx2 = combobuf[cids[i]].attribytes[0];
24431 index=3;
24432 }
24433
24434
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 27432460 times.
27440732 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
24435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27432460 times.
27432460 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
24436
2/2
✓ Branch 0 taken 27432316 times.
✓ Branch 1 taken 144 times.
27432460 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
24437 27440732 }
24438
24439 // Special case for step combos; otherwise, they act oddly in some cases
24440
8/8
✓ Branch 0 taken 6272904 times.
✓ Branch 1 taken 587360 times.
✓ Branch 2 taken 6209011 times.
✓ Branch 3 taken 63893 times.
✓ Branch 4 taken 1452 times.
✓ Branch 5 taken 649801 times.
✓ Branch 6 taken 129419 times.
✓ Branch 7 taken 127967 times.
6860264 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
24441 {
24442
7/8
✓ Branch 0 taken 6049787 times.
✓ Branch 1 taken 29805 times.
✓ Branch 2 taken 6049787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1589 times.
✓ Branch 5 taken 6048198 times.
✓ Branch 6 taken 460 times.
✓ Branch 7 taken 1129 times.
6338430 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24443 6049327 type = types[1];
24444 6079592 }
24445
24446 //Generic Step
24447
7/8
✓ Branch 0 taken 6827726 times.
✓ Branch 1 taken 29634 times.
✓ Branch 2 taken 6827726 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1930 times.
✓ Branch 5 taken 6825796 times.
✓ Branch 6 taken 796 times.
✓ Branch 7 taken 1134 times.
6857360 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24448 {
24449
4/6
✓ Branch 0 taken 2491698 times.
✓ Branch 1 taken 4335232 times.
✓ Branch 2 taken 2491698 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2491698 times.
6826930 auto rposes = diagonalMovement||NO_GRIDLOCK ?
24450 4335232 getRposes(tx+4, ty+4, tx+11, ty+11) :
24451 2491698 getRposes(tx+4, ty+4, tx+11, ty+11);
24452 6826930 auto sensRposes = getRposes(tx, ty+(bigHitbox?0:8), tx+15, ty+15);
24453 6826930 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
24454 6826930 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
24455
24456 6826930 bool hasStep[4] = {false};
24457
2/2
✓ Branch 0 taken 27307720 times.
✓ Branch 1 taken 6826930 times.
34134650 for(auto p = 0; p < 4; ++p)
24458 {
24459
2/2
✓ Branch 0 taken 12763201 times.
✓ Branch 1 taken 14544519 times.
27307720 if (rposes[p] == rpos_t::None) continue;
24460
24461
2/2
✓ Branch 0 taken 12758239 times.
✓ Branch 1 taken 89312786 times.
102071025 for (auto lyr = 0; lyr < 7; ++lyr)
24462 {
24463 89312786 auto rpos_handle = get_rpos_handle(rposes[p], lyr);
24464
4/4
✓ Branch 0 taken 89047010 times.
✓ Branch 1 taken 265776 times.
✓ Branch 2 taken 89050860 times.
✓ Branch 3 taken 261926 times.
89312786 if ((z > 0 || fakez > 0) && !(rpos_handle.base_scr()->flags2 & fAIRCOMBOS))
24465 261926 continue;
24466 89050860 auto& cmb = rpos_handle.combo();
24467
2/2
✓ Branch 0 taken 89045898 times.
✓ Branch 1 taken 5246030 times.
94291928 for(size_t idx = 0; idx < cmb.triggers.size(); ++idx)
24468 {
24469 5246030 auto& trig = cmb.triggers[idx];
24470
4/6
✓ Branch 0 taken 5246030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5246030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5241068 times.
✓ Branch 5 taken 4962 times.
10492060 if (trig.trigger_flags.any({TRIGFLAG_STEP,TRIGFLAG_STEPSENS})
24471
2/2
✓ Branch 0 taken 4962 times.
✓ Branch 1 taken 5241068 times.
5246030 || types[p] == cSTEP)
24472 {
24473 4962 hasStep[p] = true;
24474 4962 break;
24475 }
24476 5241068 }
24477
2/2
✓ Branch 0 taken 89045898 times.
✓ Branch 1 taken 4962 times.
89050860 if(hasStep[p])
24478 4962 break;
24479 89045898 }
24480 12763201 }
24481 6826930 bool canNormalStep = true;
24482
2/2
✓ Branch 0 taken 1499 times.
✓ Branch 1 taken 6832495 times.
6833994 for(auto p = 0; p < 4; ++p)
24483 {
24484
2/2
✓ Branch 0 taken 6828813 times.
✓ Branch 1 taken 3682 times.
6832495 if(rposes[p] == rpos_t::None) continue;
24485
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 6825431 times.
6828813 if(!hasStep[p])
24486 {
24487 6825431 canNormalStep = false;
24488 6825431 break;
24489 }
24490 3382 }
24491
2/2
✓ Branch 0 taken 27307720 times.
✓ Branch 1 taken 6826930 times.
34134650 for (auto p = 0; p < 4; ++p)
24492 {
24493
2/2
✓ Branch 0 taken 191154040 times.
✓ Branch 1 taken 27307720 times.
218461760 for (auto lyr = 0; lyr < 7; ++lyr)
24494 {
24495
2/2
✓ Branch 0 taken 101811633 times.
✓ Branch 1 taken 89342407 times.
191154040 if (rposes[p] != rpos_t::None)
24496 {
24497 89342407 auto rpos_handle = get_rpos_handle(rposes[p], lyr);
24498
5/8
✓ Branch 0 taken 89324963 times.
✓ Branch 1 taken 17444 times.
✓ Branch 2 taken 17444 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89324963 times.
✓ Branch 5 taken 17444 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
89362859 bool did_trig = canNormalStep && trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24499 3008 return trig.trigger_flags.get(TRIGFLAG_STEP);
24500 });
24501
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 89342292 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 58 times.
89342407 if (did_trig && rposes[p] == sensRposes[p]) continue;
24502 89342349 }
24503
2/2
✓ Branch 0 taken 99391936 times.
✓ Branch 1 taken 91762046 times.
191153982 if (sensRposes[p] != rpos_t::None)
24504 {
24505 91762046 auto rpos_handle = get_rpos_handle(sensRposes[p], lyr);
24506
1/2
✓ Branch 0 taken 91762046 times.
✗ Branch 1 not taken.
97903049 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24507 6141003 return trig.trigger_flags.get(TRIGFLAG_STEPSENS);
24508 });
24509 91762046 }
24510 191153982 }
24511 27307720 }
24512
24513 207042239 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
24514 200215309 bool found = false;
24515
2/2
✓ Branch 0 taken 400430618 times.
✓ Branch 1 taken 200215309 times.
600645927 for (int xch = 0; xch < 2; ++xch)
24516 {
24517
2/2
✓ Branch 0 taken 800861236 times.
✓ Branch 1 taken 400430618 times.
1201291854 for(int ych = 0; ych < 2; ++ych)
24518 {
24519
2/2
✓ Branch 0 taken 800245544 times.
✓ Branch 1 taken 615692 times.
800861236 if (ffcIsAt(ffc_handle, xPoses[xch], yPoses[ych]))
24520 {
24521 615692 found = true;
24522 615692 }
24523 800861236 }
24524 400430618 }
24525
2/2
✓ Branch 0 taken 199988968 times.
✓ Branch 1 taken 226341 times.
200215309 if (found)
24526 {
24527
1/2
✓ Branch 0 taken 226341 times.
✗ Branch 1 not taken.
227172 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24528
2/4
✓ Branch 0 taken 831 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 831 times.
831 return trig.trigger_flags.any({TRIGFLAG_STEP,TRIGFLAG_STEPSENS});
24529 });
24530 226341 }
24531 200215309 });
24532 6826930 }
24533
24534
2/2
✓ Branch 0 taken 6854980 times.
✓ Branch 1 taken 2380 times.
6857360 if(isDiving()) //Dive-> triggerflag
24535 {
24536 2380 rpos_t rpos = COMBOPOS_REGION(x+8,y+8);
24537 2380 int x1=x,x2=x+15,y1=y+(bigHitbox?0:8),y2=y+15;
24538 2380 int xposes[] = {x1,x1,x2,x2};
24539 2380 int yposes[] = {y1,y2,y1,y2};
24540 2380 auto rposes = getRposes(x1,y1,x2,y2);
24541
2/2
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 2380 times.
19040 for(auto lyr = 0; lyr < 7; ++lyr)
24542 {
24543 16660 bool didtrig = false;
24544 16660 auto rpos_handle = get_rpos_handle(rpos, lyr);
24545 16660 auto& cmb = rpos_handle.combo();
24546 16660 auto cid = rpos_handle.data();
24547
1/2
✓ Branch 0 taken 16660 times.
✗ Branch 1 not taken.
18851 didtrig = trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24548 2191 return trig.trigger_flags.get(TRIGFLAG_DIVETRIG);
24549 });
24550
2/2
✓ Branch 0 taken 66640 times.
✓ Branch 1 taken 16660 times.
83300 for(auto q = 0; q < 4; ++q)
24551 {
24552
2/2
✓ Branch 0 taken 33047 times.
✓ Branch 1 taken 33593 times.
66640 if(rposes[q] == rpos_t::None) continue;
24553
3/4
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 16933 times.
✓ Branch 2 taken 16660 times.
✗ Branch 3 not taken.
33593 if(rposes[q] == rpos && didtrig) continue;
24554
24555 33593 auto rpos_handle_2 = get_rpos_handle(rposes[q], lyr);
24556
1/2
✓ Branch 0 taken 33593 times.
✗ Branch 1 not taken.
38102 trig_each_combo_trigger(rpos_handle_2, [&](combo_trigger const& trig){
24557 4509 return trig.trigger_flags.get(TRIGFLAG_DIVESENSTRIG);
24558 });
24559 33593 }
24560 16660 }
24561
24562 68688 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
24563
2/2
✓ Branch 0 taken 66272 times.
✓ Branch 1 taken 36 times.
66308 if(ffcIsAt(ffc_handle, x+8, y+8))
24564 {
24565
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
36 if(trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24566 return trig.trigger_flags.get(TRIGFLAG_DIVETRIG);
24567 })) return;
24568 36 }
24569
2/2
✓ Branch 0 taken 66308 times.
✓ Branch 1 taken 265232 times.
331540 for(auto q = 0; q < 4; ++q)
24570 {
24571
2/2
✓ Branch 0 taken 265143 times.
✓ Branch 1 taken 89 times.
265232 if(ffcIsAt(ffc_handle, xposes[q], yposes[q]))
24572 {
24573
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24574 return trig.trigger_flags.get(TRIGFLAG_DIVESENSTRIG);
24575 })) break;
24576 89 }
24577 265232 }
24578 66308 });
24579 2380 }
24580
24581 //
24582 // Now, let's check for Save combos...
24583 //
24584 6857360 x1 = tx+4;
24585 6857360 x2 = tx+11;
24586 6857360 y1 = ty+4;
24587 6857360 y2 = ty+11;
24588
24589 6857360 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
24590 6857360 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
24591 6857360 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
24592 6857360 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
24593
24594 6857360 cids[0] = rpos_handles[0].data();
24595 6857360 cids[1] = rpos_handles[1].data();
24596 6857360 cids[2] = rpos_handles[2].data();
24597 6857360 cids[3] = rpos_handles[3].data();
24598
24599 6857360 types[0] = rpos_handles[0].ctype();
24600
2/2
✓ Branch 0 taken 6682498 times.
✓ Branch 1 taken 174862 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y1))
24601 {
24602 174862 types[0] = ffc_handle->ctype();
24603 174862 cids[0] = ffc_handle->data();
24604 174862 }
24605
24606 6857360 types[1] = rpos_handles[1].ctype();
24607
2/2
✓ Branch 0 taken 6727455 times.
✓ Branch 1 taken 129905 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y2))
24608 {
24609 129905 types[1] = ffc_handle->ctype();
24610 129905 cids[1] = ffc_handle->data();
24611 129905 }
24612
24613 6857360 types[2] = rpos_handles[2].ctype();
24614
2/2
✓ Branch 0 taken 6683061 times.
✓ Branch 1 taken 174299 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y1))
24615 {
24616 174299 types[2] = ffc_handle->ctype();
24617 174299 cids[2] = ffc_handle->data();
24618 174299 }
24619
24620 6857360 types[3] = rpos_handles[3].ctype();
24621
2/2
✓ Branch 0 taken 6726872 times.
✓ Branch 1 taken 130488 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y2))
24622 {
24623 130488 types[3] = ffc_handle->ctype();
24624 130488 cids[3] = ffc_handle->data();
24625 130488 }
24626
24627
2/2
✓ Branch 0 taken 6857360 times.
✓ Branch 1 taken 27441056 times.
34298416 for(int32_t i=0; i<4; i++)
24628 {
24629
2/2
✓ Branch 0 taken 27440732 times.
✓ Branch 1 taken 324 times.
27441056 if(combobuf[cids[i]].only_gentrig)
24630 {
24631
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
24632 {
24633 types[i] = cNONE;
24634 setsave = false;
24635 break;
24636 }
24637 324 }
24638
2/2
✓ Branch 0 taken 27439770 times.
✓ Branch 1 taken 1286 times.
27441056 if(types[i]==cSAVE) setsave=true;
24639
24640
1/2
✓ Branch 0 taken 27441056 times.
✗ Branch 1 not taken.
27441056 if(types[i]==cSAVE2) setsave=true;
24641 27441056 }
24642
24643
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 6856929 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
6857360 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24644 {
24645 229 last_savepoint_id = cids[0];
24646 229 type = types[0];
24647 229 }
24648 //
24649 // Now, let's check for Drowning combos...
24650 //
24651
4/4
✓ Branch 0 taken 2625640 times.
✓ Branch 1 taken 4231720 times.
✓ Branch 2 taken 2904 times.
✓ Branch 3 taken 2622736 times.
6857360 if(get_qr(qr_DROWN) || CanSideSwim())
24652 {
24653 4234624 y1 = ty+9;
24654 4234624 y2 = ty+15;
24655
2/2
✓ Branch 0 taken 1092995 times.
✓ Branch 1 taken 3141629 times.
4234624 if (get_qr(qr_SMARTER_WATER))
24656 {
24657
4/4
✓ Branch 0 taken 11287 times.
✓ Branch 1 taken 1081708 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8892 times.
1101909 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
24658
2/2
✓ Branch 0 taken 10186 times.
✓ Branch 1 taken 1101 times.
11287 iswaterex_z3(0, -1, x1, y2, true, false) &&
24659
2/2
✓ Branch 0 taken 8914 times.
✓ Branch 1 taken 1272 times.
10186 iswaterex_z3(0, -1, x2, y1, true, false) &&
24660 8914 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
24661 1092995 }
24662 else
24663 {
24664 3141629 types[0] = COMBOTYPE(x1,y1);
24665
2/2
✓ Branch 0 taken 3035678 times.
✓ Branch 1 taken 105951 times.
3141629 if (auto ffc_handle = getFFCAt(x1, y1))
24666 105951 types[0] = ffc_handle->ctype();
24667
24668 3141629 types[1] = COMBOTYPE(x1,y2);
24669
2/2
✓ Branch 0 taken 3049172 times.
✓ Branch 1 taken 92457 times.
3141629 if (auto ffc_handle = getFFCAt(x1, y2))
24670 92457 types[1] = ffc_handle->ctype();
24671
24672 3141629 types[2] = COMBOTYPE(x2,y1);
24673
2/2
✓ Branch 0 taken 3033811 times.
✓ Branch 1 taken 107818 times.
3141629 if (auto ffc_handle = getFFCAt(x2, y1))
24674 107818 types[2] = ffc_handle->ctype();
24675
24676 3141629 types[3] = COMBOTYPE(x2,y2);
24677
2/2
✓ Branch 0 taken 3045561 times.
✓ Branch 1 taken 96068 times.
3141629 if (auto ffc_handle = getFFCAt(x2, y2))
24678 96068 types[3] = ffc_handle->ctype();
24679
24680 3141629 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
24681
2/2
✓ Branch 0 taken 3040283 times.
✓ Branch 1 taken 101346 times.
3141629 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
24682 101346 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
24683
24684
5/6
✓ Branch 0 taken 9045 times.
✓ Branch 1 taken 3132584 times.
✓ Branch 2 taken 8649 times.
✓ Branch 3 taken 396 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8168 times.
3149797 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
24685
3/4
✓ Branch 0 taken 8168 times.
✓ Branch 1 taken 481 times.
✓ Branch 2 taken 8168 times.
✗ Branch 3 not taken.
8649 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
24686 8168 water = typec;
24687 }
24688 4234624 }
24689
24690 // Pits (aka direct warps) have a bigger 'hitbox' than stairs...
24691 6857360 x1 = tx+7;
24692 6857360 x2 = tx+8;
24693 6857360 y1 = ty+7+(bigHitbox?0:4);
24694 6857360 y2 = ty+8+(bigHitbox?0:4);
24695
24696 6857360 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
24697 6857360 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
24698 6857360 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
24699 6857360 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
24700
24701 6857360 cids[0] = rpos_handles[0].data();
24702 6857360 cids[1] = rpos_handles[1].data();
24703 6857360 cids[2] = rpos_handles[2].data();
24704 6857360 cids[3] = rpos_handles[3].data();
24705
24706 6857360 types[0] = rpos_handles[0].ctype();
24707 6857360 scrs[0] = rpos_handles[0].scr;
24708
2/2
✓ Branch 0 taken 6726288 times.
✓ Branch 1 taken 131072 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y1))
24709 {
24710 131072 types[0] = ffc_handle->ctype();
24711 131072 cids[0] = ffc_handle->data();
24712 131072 scrs[0] = ffc_handle->scr;
24713 131072 }
24714
24715 6857360 types[1] = rpos_handles[1].ctype();
24716 6857360 scrs[1] = rpos_handles[1].scr;
24717
2/2
✓ Branch 0 taken 6727327 times.
✓ Branch 1 taken 130033 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y2))
24718 {
24719 130033 types[1] = ffc_handle->ctype();
24720 130033 cids[1] = ffc_handle->data();
24721 130033 scrs[1] = ffc_handle->scr;
24722 130033 }
24723
24724 6857360 types[2] = rpos_handles[2].ctype();
24725 6857360 scrs[2] = rpos_handles[2].scr;
24726
2/2
✓ Branch 0 taken 6725619 times.
✓ Branch 1 taken 131741 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y1))
24727 {
24728 131741 types[2] = ffc_handle->ctype();
24729 131741 cids[2] = ffc_handle->data();
24730 131741 scrs[2] = ffc_handle->scr;
24731 131741 }
24732
24733 6857360 types[3] = rpos_handles[3].ctype();
24734 6857360 scrs[3] = rpos_handles[3].scr;
24735
2/2
✓ Branch 0 taken 6726626 times.
✓ Branch 1 taken 130734 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y2))
24736 {
24737 130734 types[3] = ffc_handle->ctype();
24738 130734 cids[3] = ffc_handle->data();
24739 130734 scrs[3] = ffc_handle->scr;
24740 130734 }
24741
24742
2/2
✓ Branch 0 taken 27441056 times.
✓ Branch 1 taken 6857360 times.
34298416 for(int32_t i=0; i<4; i++)
24743 {
24744
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 27440792 times.
27441056 if(combobuf[cids[i]].only_gentrig)
24745 {
24746 264 types[i] = cNONE;
24747 264 continue;
24748 }
24749
2/2
✓ Branch 0 taken 3037 times.
✓ Branch 1 taken 27437755 times.
27440792 if(types[i]==cPIT)
24750 {
24751 3037 index=0;
24752 3037 warpsfx2 = combobuf[cids[i]].attribytes[0];
24753 3037 }
24754
2/2
✓ Branch 0 taken 5004 times.
✓ Branch 1 taken 27432751 times.
27437755 else if(types[i]==cPITB)
24755 {
24756 5004 types[i]=cPIT;
24757 5004 index=1;
24758 5004 warpsfx2 = combobuf[cids[i]].attribytes[0];
24759 5004 }
24760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27432751 times.
27432751 else if(types[i]==cPITC)
24761 {
24762 types[i]=cPIT;
24763 index=2;
24764 warpsfx2 = combobuf[cids[i]].attribytes[0];
24765 }
24766
2/2
✓ Branch 0 taken 27432749 times.
✓ Branch 1 taken 2 times.
27432751 else if(types[i]==cPITD)
24767 {
24768 2 types[i]=cPIT;
24769 2 index=3;
24770 2 warpsfx2 = combobuf[cids[i]].attribytes[0];
24771 2 }
24772 27440792 }
24773
24774
8/8
✓ Branch 0 taken 6858259 times.
✓ Branch 1 taken 2255 times.
✓ Branch 2 taken 6858241 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6858043 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 1778 times.
✓ Branch 7 taken 6856265 times.
6857360 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
24775
3/8
✓ Branch 0 taken 2221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2221 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2221 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6470 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_qr(qr_MSGFREEZE)))
24776 2221 type = cPIT;
24777
24778 //
24779 // Time to act on our results for type, flag, flag2 and flag3...
24780 //
24781
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 6858257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
6858486 if(type==cSAVE&&cur_screen<128)
24782 229 *ls=1;
24783
24784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6858486 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6858486 if(type==cSAVE2&&cur_screen<128)
24785 *ls=2;
24786
24787
8/8
✓ Branch 0 taken 6849914 times.
✓ Branch 1 taken 8572 times.
✓ Branch 2 taken 6833499 times.
✓ Branch 3 taken 16415 times.
✓ Branch 4 taken 6832969 times.
✓ Branch 5 taken 530 times.
✓ Branch 6 taken 13806 times.
✓ Branch 7 taken 6846775 times.
6858486 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
24788 {
24789 39323 fairycircle(REFILL_LIFE);
24790
24791
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 34991 times.
39323 if(fairyclk!=0) return;
24792 4332 }
24793
24794
7/8
✓ Branch 0 taken 6837287 times.
✓ Branch 1 taken 13820 times.
✓ Branch 2 taken 6837205 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 6837205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13834 times.
✓ Branch 7 taken 6851039 times.
6851107 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
24795 {
24796 27736 fairycircle(REFILL_MAGIC);
24797
24798
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 times.
27736 if(fairyclk!=0) return;
24799 1 }
24800
24801
7/8
✓ Branch 0 taken 6837172 times.
✓ Branch 1 taken 13868 times.
✓ Branch 2 taken 6836991 times.
✓ Branch 3 taken 181 times.
✓ Branch 4 taken 6836991 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13902 times.
✓ Branch 7 taken 6850893 times.
6851040 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
24802 {
24803 27951 fairycircle(REFILL_ALL);
24804
24805
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
27951 if(fairyclk!=0) return;
24806 19 }
24807
24808 // Just in case Hero was moved off of the fairy flag
24809
1/2
✓ Branch 0 taken 6850912 times.
✗ Branch 1 not taken.
6850912 if(refilling==REFILL_FAIRYDONE)
24810 {
24811 fairycircle(REFILL_NONE);
24812
24813 if(fairyclk!=0) return;
24814 }
24815
24816
6/8
✓ Branch 0 taken 6837000 times.
✓ Branch 1 taken 13912 times.
✓ Branch 2 taken 6837000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6837000 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13922 times.
✓ Branch 7 taken 6850786 times.
6850912 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
24817 {
24818 27834 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
24819 27834 win_game();
24820 27834 return;
24821 }
24822
24823
4/4
✓ Branch 0 taken 6818144 times.
✓ Branch 1 taken 32642 times.
✓ Branch 2 taken 6832210 times.
✓ Branch 3 taken 18576 times.
6850786 if((z>0 || fakez>0) && !(hero_scr->flags2&fAIRCOMBOS))
24824 18576 return;
24825
24826
4/4
✓ Branch 0 taken 6815793 times.
✓ Branch 1 taken 16417 times.
✓ Branch 2 taken 723 times.
✓ Branch 3 taken 6815070 times.
6832210 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
24827 {
24828
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 15051 times.
✓ Branch 2 taken 15417 times.
✓ Branch 3 taken 16618 times.
17140 if (COMBOPOS_REGION(tx+8, ty+8)!=stepsecret || get_qr(qr_TRIGGERSREPEAT))
24829 {
24830 30468 stepsecret = COMBOPOS_REGION(tx+8, ty+8);
24831 30468 auto rpos_handle = get_rpos_handle(stepsecret, 0);
24832 30468 sfx(combobuf[MAPCOMBO(rpos_handle)].attribytes[0],pan((int32_t)x));
24833
24834
4/4
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 2631 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 200 times.
30468 if(type==cTRIGFLAG && canPermSecret(cur_dmap, rpos_handle.screen))
24835 {
24836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(!(rpos_handle.scr->flags5&fTEMPSECRETS)) setmapflag(rpos_handle.scr, mSECRET);
24837
24838 200 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), false);
24839 200 }
24840 else
24841 {
24842 2658 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24843 2658 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), only16_31);
24844 }
24845 2858 }
24846 19476 }
24847
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 6813655 times.
6815070 else if(!didstrig)
24848 {
24849 6813655 stepsecret = rpos_t::None;
24850 6813655 }
24851
24852 //Better? Dock collision
24853
24854 // Drown if:
24855 // * Water (obviously walkable),
24856 // * Quest Rule allows it,
24857 // * Not on stepladder,
24858 // * Not jumping,
24859 // * Not hovering,
24860 // * Not rafting,
24861 // * Not swallowed,
24862 // * Not a dried lake.
24863
24864 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
24865
9/12
✓ Branch 0 taken 16844 times.
✓ Branch 1 taken 6780190 times.
✓ Branch 2 taken 16261 times.
✓ Branch 3 taken 583 times.
✓ Branch 4 taken 16261 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10695 times.
✓ Branch 7 taken 5566 times.
✓ Branch 8 taken 10695 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10695 times.
6844713 if(water > 0 && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE
24866
4/8
✓ Branch 0 taken 10695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10695 times.
✗ Branch 7 not taken.
10695 && ((get_qr(qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim())
24867
4/4
✓ Branch 0 taken 10695 times.
✓ Branch 1 taken 10695 times.
✓ Branch 2 taken 10695 times.
✓ Branch 3 taken 10695 times.
10695 && (sideview_mode() || !platform_ffc))
24868 {
24869
7/8
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 191 times.
✓ Branch 2 taken 10501 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2518 times.
✓ Branch 5 taken 7983 times.
✓ Branch 6 taken 2518 times.
✗ Branch 7 not taken.
10695 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
24870 {
24871
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!(ladderx+laddery)) drownCombo = water;
24872
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 190 times.
194 if (combobuf[water].usrflags&cflag1) Drown(1);
24873 190 else Drown();
24874
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 16 times.
194 if(byte drown_sfx = combobuf[water].attribytes[4])
24875 16 sfx(drown_sfx, pan(int32_t(x)));
24876 194 }
24877
2/2
✓ Branch 0 taken 10237 times.
✓ Branch 1 taken 264 times.
10501 else if (!isSwimming())
24878 {
24879 264 SetSwim();
24880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if (!IsSideSwim()) attackclk = charging = spins = 0;
24881 264 landswim=0;
24882 264 return;
24883 }
24884 10431 }
24885
24886
24887
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6817826 times.
6818160 if(type==cSTEP)
24888 {
24889 334 rpos_t next_step = COMBOPOS_REGION(tx+8, ty+8);
24890
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 186 times.
334 if (next_step != stepnext)
24891 {
24892 186 stepnext = next_step;
24893 186 auto rpos_handle = get_rpos_handle(stepnext, 0);
24894 186 int cid = MAPCOMBO(rpos_handle);
24895
24896 if
24897 (
24898
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 19 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
24899
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 (!combobuf[cid].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
24900 && /*HEAVY*/
24901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24902 )
24903 {
24904 167 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
24905 167 rpos_handle.increment_data();
24906 167 }
24907
24908 if
24909 (
24910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
24911 (!combobuf[cid].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
24912 && /*HEAVY*/
24913 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24914 )
24915 {
24916 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
24917 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
24918 if (rpos_handle.data() == cid)
24919 rpos_handle.increment_data();
24920 });
24921 }
24922
24923 if
24924 (
24925
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 179 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
24926
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
24927 && /*HEAVY*/
24928
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
24929 )
24930 {
24931 7 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
24932
24933 1239 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
24934
2/2
✓ Branch 0 taken 1051 times.
✓ Branch 1 taken 181 times.
1232 if (isStepType(rpos_handle.ctype()))
24935 181 rpos_handle.increment_data();
24936 1232 });
24937 7 }
24938 186 }
24939 334 }
24940
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6817826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6817826 else if(type==cSTEPSFX && action == walking)
24941 {
24942 trigger_stepfx(get_rpos_handle_for_world_xy(tx + 8, ty + 8, 0), true);
24943 }
24944 6817826 else stepnext = rpos_t::None;
24945
24946 6818160 detail_int[0]=tx;
24947 6818160 detail_int[1]=ty;
24948
24949
24950
8/8
✓ Branch 0 taken 6817702 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 881 times.
✓ Branch 3 taken 6817279 times.
✓ Branch 4 taken 6815293 times.
✓ Branch 5 taken 1986 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
6818185 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
24951
5/6
✓ Branch 0 taken 6814341 times.
✓ Branch 1 taken 952 times.
✓ Branch 2 taken 6814320 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 6814320 times.
✗ Branch 5 not taken.
6815293 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
24952
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6814295 times.
6814320 !(type==cDIVEWARP && isDiving()))
24953 6814306 {
24954 RaftingStuff:
24955
2/2
✓ Branch 0 taken 6813747 times.
✓ Branch 1 taken 559 times.
6814306 if (get_qr(qr_BETTER_RAFT_2))
24956 {
24957 559 bool doraft = true;
24958
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
24959 {
24960
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
24961 {
24962 3 doraft = false;
24963 3 }
24964 3 }
24965 //if (mfRAFT)
24966 int32_t rafttypes[2];
24967 559 int32_t raftx1 = tx+6;
24968 559 int32_t raftx2 = tx+9;
24969 559 int32_t rafty = ty+11;
24970 int32_t raftflags[3];
24971 559 rafttypes[0]=rafttypes[1]=-1;
24972 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
24973 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
24974 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
24975
24976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
24977 559 raftflags[0] = rafttypes[0];
24978
24979
24980 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
24981 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
24982
24983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
24984 559 raftflags[1] = rafttypes[0];
24985
24986 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
24987 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
24988
24989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
24990 559 raftflags[2] = rafttypes[0];
24991
24992
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
24993 {
24994
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
24995 {
24996 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
24997 {
24998 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
24999 {
25000 reset_swordcharge();
25001 action=rafting; FFCore.setHeroAction(rafting);
25002 raftclk=0;
25003 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25004 else sfx(get_scr_for_world_xy(tx,ty+11)->secretsfx);
25005 }
25006 else if (get_qr(qr_BETTER_RAFT) && doraft)
25007 {
25008 for (int32_t i = 0; i < 4; ++i)
25009 {
25010 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
25011 {
25012 reset_swordcharge();
25013 action=rafting; FFCore.setHeroAction(rafting);
25014 raftclk=0;
25015 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25016 else sfx(get_scr_for_world_xy(tx+8,ty+11)->secretsfx);
25017 dir = i;
25018 break;
25019 }
25020 }
25021 }
25022 }
25023 }
25024 1677 }
25025 559 }
25026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6814306 times.
6814306 if (RaftPass) return;
25027
3/3
✓ Branch 0 taken 34031 times.
✓ Branch 1 taken 6779215 times.
✓ Branch 2 taken 1060 times.
6814306 switch(flag)
25028 {
25029 case mfDIVE_ITEM:
25030
6/8
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1036 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
1060 if(isDiving() && (!getmapflag(flag_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag_scr->flags9&fBELOWRETURN)))
25031 {
25032 30 additem(x, y, flag_scr->catchall,
25033 15 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25034 15 sfx(flag_scr->secretsfx);
25035 15 }
25036
25037 1060 return;
25038
25039 case mfRAFT:
25040 case mfRAFT_BRANCH:
25041
25042 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34031 times.
34031 if (!get_qr(qr_BETTER_RAFT_2))
25044 {
25045 34031 bool doraft = true;
25046
5/6
✓ Branch 0 taken 34031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2122 times.
✓ Branch 3 taken 31909 times.
✓ Branch 4 taken 576 times.
✓ Branch 5 taken 1546 times.
34031 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25047 {
25048
5/6
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 738 times.
✓ Branch 4 taken 785 times.
✓ Branch 5 taken 23 times.
1546 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25049 {
25050 785 doraft = false;
25051 785 }
25052 1546 }
25053
13/16
✓ Branch 0 taken 31056 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 27774 times.
✓ Branch 4 taken 3262 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 3251 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 3251 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3251 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3251 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1531 times.
✓ Branch 15 taken 1720 times.
34031 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25054 {
25055
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
1720 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
25056 {
25057 355 reset_swordcharge();
25058 355 action=rafting; FFCore.setHeroAction(rafting);
25059 355 raftclk=0;
25060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 355 times.
355 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25061 355 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25062 355 }
25063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1365 else if (get_qr(qr_BETTER_RAFT) && doraft)
25064 {
25065 for (int32_t i = 0; i < 4; ++i)
25066 {
25067 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25068 {
25069 reset_swordcharge();
25070 action=rafting; FFCore.setHeroAction(rafting);
25071 raftclk=0;
25072 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25073 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25074 dir = i;
25075 break;
25076 }
25077 }
25078 }
25079 1720 }
25080 34031 }
25081
25082 34031 return;
25083
25084 default:
25085 6779215 break;
25086 //return;
25087 }
25088
25089
2/3
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 6778941 times.
✗ Branch 2 not taken.
6779215 switch(flag2)
25090 {
25091 case mfDIVE_ITEM:
25092 if(isDiving() && (!getmapflag(flag2_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag2_scr->flags9&fBELOWRETURN)))
25093 {
25094 additem(x, y, flag2_scr->catchall,
25095 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag2_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25096 sfx(flag2_scr->secretsfx);
25097 }
25098
25099 return;
25100
25101 case mfRAFT:
25102 case mfRAFT_BRANCH:
25103
25104 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if (!get_qr(qr_BETTER_RAFT_2))
25106 {
25107 274 bool doraft = true;
25108
2/6
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
274 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25109 {
25110 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25111 {
25112 doraft = false;
25113 }
25114 }
25115
10/16
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 135 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 135 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 121 times.
✓ Branch 15 taken 14 times.
274 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25116 {
25117
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
14 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25118 {
25119 5 reset_swordcharge();
25120 5 action=rafting; FFCore.setHeroAction(rafting);
25121 5 raftclk=0;
25122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25123 5 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25124 5 }
25125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 else if (get_qr(qr_BETTER_RAFT) && doraft)
25126 {
25127 for (int32_t i = 0; i < 4; ++i)
25128 {
25129 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25130 {
25131 reset_swordcharge();
25132 action=rafting; FFCore.setHeroAction(rafting);
25133 raftclk=0;
25134 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25135 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25136 dir = i;
25137 break;
25138 }
25139 }
25140 }
25141 14 }
25142 274 }
25143
25144 274 return;
25145
25146 default:
25147 6778941 break;
25148 //return;
25149 }
25150
25151
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6778941 times.
✗ Branch 2 not taken.
6778941 switch(flag3)
25152 {
25153 case mfDIVE_ITEM:
25154 if(isDiving() && (!getmapflag(flag3_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag3_scr->flags9&fBELOWRETURN)))
25155 {
25156 additem(x, y, flag3_scr->catchall,
25157 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag3_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25158 sfx(flag3_scr->secretsfx);
25159 }
25160
25161 return;
25162
25163 case mfRAFT:
25164 case mfRAFT_BRANCH:
25165
25166 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25167 if (!get_qr(qr_BETTER_RAFT_2))
25168 {
25169 bool doraft = true;
25170 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25171 {
25172 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25173 {
25174 doraft = false;
25175 }
25176 }
25177 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25178 {
25179 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25180 {
25181 reset_swordcharge();
25182 action=rafting; FFCore.setHeroAction(rafting);
25183 raftclk=0;
25184 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25185 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25186 }
25187 else if (get_qr(qr_BETTER_RAFT) && doraft)
25188 {
25189 for (int32_t i = 0; i < 4; ++i)
25190 {
25191 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25192 {
25193 reset_swordcharge();
25194 action=rafting; FFCore.setHeroAction(rafting);
25195 raftclk=0;
25196 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
25197 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25198 dir = i;
25199 break;
25200 }
25201 }
25202 }
25203 }
25204 }
25205
25206 return;
25207
25208 default:
25209 6778941 return;
25210 }
25211 }
25212
25213 // Either the screen the hero is currently in, or if in a 0x80 room the screen player came from.
25214
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3797 times.
3854 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : hero_scr;
25215
25216
3/4
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 3854 times.
✗ Branch 3 not taken.
3854 if((type==cCAVE || type==cCAVE2) && (base_scr->tilewarptype[index]==wtNOWARP)) return;
25217
25218 3854 bool skippedaframe=false;
25219
25220
6/6
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 2973 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 1986 times.
✓ Branch 5 taken 987 times.
3854 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
25221 {
25222 // Stop music only if:
25223 // * entering a Guy Cave
25224 // * warping to a DMap whose music is different.
25225
25226 2867 int32_t tdm = base_scr->tilewarpdmap[index];
25227
25228
2/2
✓ Branch 0 taken 957 times.
✓ Branch 1 taken 1910 times.
2867 if(base_scr->tilewarptype[index]<=wtPASS)
25229 {
25230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 957 times.
957 if (FFCore.can_dmap_change_music(tdm))
25231 {
25232
3/4
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
957 if ((DMaps[cur_dmap].flags & dmfCAVES) && base_scr->tilewarptype[index] == wtCAVE)
25233 488 music_stop();
25234 957 }
25235 957 }
25236 else
25237 {
25238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (FFCore.can_dmap_change_music(tdm))
25239 {
25240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (zcmusic != NULL)
25241 {
25242 if (strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
25243 (zcmusic->type == ZCMF_GME && zcmusic->track != DMaps[tdm].tmusictrack))
25244 music_stop();
25245 }
25246
2/4
✓ Branch 0 taken 1910 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1910 times.
1910 else if (DMaps[hero_scr->tilewarpdmap[index]].midi != (currmidi - ZC_MIDI_COUNT + 4) &&
25247 1910 get_canonical_scr(DMaps[tdm].map, base_scr->tilewarpscr[index] + DMaps[tdm].xoff)->screen_midi != (currmidi - ZC_MIDI_COUNT + 4))
25248 1910 music_stop();
25249 1910 }
25250 }
25251
25252 2867 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25253
5/6
✓ Branch 0 taken 957 times.
✓ Branch 1 taken 1910 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 488 times.
2867 bool opening = (base_scr->tilewarptype[index]<=wtPASS && !(DMaps[cur_dmap].flags&dmfCAVES && base_scr->tilewarptype[index]==wtCAVE)
25254 2398 ? false : COOLSCROLL);
25255
25256 2867 FFCore.warpScriptCheck();
25257 2867 draw_screen();
25258 2867 advanceframe(true);
25259
25260 2867 skippedaframe=true;
25261
25262
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 2444 times.
2867 if(type==cCAVE2) walkup2(opening);
25263
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 458 times.
2444 else if(type==cCAVE) walkdown(opening);
25264 2867 }
25265
25266
2/2
✓ Branch 0 taken 2902 times.
✓ Branch 1 taken 952 times.
3854 if(type==cPIT)
25267 {
25268 952 setpit();
25269 952 warp_sound = warpsfx2;
25270 952 }
25271
25272 3854 mapscr* scr = nullptr;
25273
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7708 times.
✓ Branch 2 taken 3854 times.
✓ Branch 3 taken 3854 times.
7708 for (int i = 0; i < 4 && !scr; i++) scr = scrs[i];
25274
1/2
✓ Branch 0 taken 3854 times.
✗ Branch 1 not taken.
3854 if (!scr) scr = hero_scr;
25275
25276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
3911 if (!is_in_scrolling_region()
25277
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 2 times.
3854 && DMaps[cur_dmap].flags&dmf3STAIR
25278
4/4
✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 2559 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 57 times.
3852 && (cur_screen==129 || !(DMaps[cur_dmap].flags&dmfGUYCAVES))
25279
7/8
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 157 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 157 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 157 times.
1293 && (specialcave > 0 && DMaps[cur_dmap].flags & dmfGUYCAVES ? special_warp_return_scr : scr)->room==rWARP && type==cSTAIR)
25280 {
25281
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(!skippedaframe)
25282 {
25283 FFCore.warpScriptCheck();
25284 draw_screen();
25285 advanceframe(true);
25286 }
25287
25288 // "take any road you want"
25289
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11 times.
57 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
25290 57 int32_t code = WARPCODE(cur_dmap,home_screen,dw);
25291
25292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(code>-1)
25293 {
25294 57 bool changedlevel = false;
25295 57 bool changeddmap = false;
25296
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(cur_dmap != code>>8)
25297 {
25298 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25299 15 changeddmap = true;
25300 15 }
25301
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(dlevel != DMaps[code>>8].level)
25302 {
25303 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25304 changedlevel = true;
25305 }
25306 57 cur_dmap = code>>8;
25307 57 dlevel = DMaps[cur_dmap].level;
25308
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(changeddmap)
25309 {
25310 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25311 15 }
25312
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(changedlevel)
25313 {
25314 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25315 }
25316
25317 57 cur_map = DMaps[cur_dmap].map;
25318 57 home_screen = (code&0xFF) + DMaps[cur_dmap].xoff;
25319 57 init_dmap();
25320
25321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(canPermSecret(cur_dmap, cur_screen))
25322 57 setmapflag_homescr(mSECRET);
25323 57 }
25324
25325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(specialcave==STAIRCAVE) exitcave();
25326
25327 57 return;
25328 }
25329
25330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797 times.
3797 if(type==cRESET)
25331 {
25332 if(!skippedaframe)
25333 {
25334 FFCore.warpScriptCheck();
25335 draw_screen();
25336 advanceframe(true);
25337 }
25338
25339 if(!(scr->noreset&mSECRET)) unsetmapflag(scr, mSECRET);
25340
25341 if(!(scr->noreset&mITEM)) unsetmapflag(scr, mITEM);
25342
25343 if(!(scr->noreset&mSPECIALITEM)) unsetmapflag(scr, mSPECIALITEM);
25344
25345 if(!(scr->noreset&mNEVERRET)) unsetmapflag(scr, mNEVERRET);
25346
25347 if(!(scr->noreset&mCHEST)) unsetmapflag(scr, mCHEST);
25348
25349 if(!(scr->noreset&mLOCKEDCHEST)) unsetmapflag(scr, mLOCKEDCHEST);
25350
25351 if(!(scr->noreset&mBOSSCHEST)) unsetmapflag(scr, mBOSSCHEST);
25352
25353 if(!(scr->noreset&mLOCKBLOCK)) unsetmapflag(scr, mLOCKBLOCK);
25354
25355 if(!(scr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(scr, mBOSSLOCKBLOCK);
25356
25357 if(isdungeon())
25358 {
25359 if(!(scr->noreset&mDOOR_LEFT)) unsetmapflag(scr, mDOOR_LEFT);
25360
25361 if(!(scr->noreset&mDOOR_RIGHT)) unsetmapflag(scr, mDOOR_RIGHT);
25362
25363 if(!(scr->noreset&mDOOR_DOWN)) unsetmapflag(scr, mDOOR_DOWN);
25364
25365 if(!(scr->noreset&mDOOR_UP)) unsetmapflag(scr, mDOOR_UP);
25366 }
25367
25368 setpit();
25369 sdir=dir;
25370 dowarp(scr, 4, 0, warpsfx2);
25371 }
25372 else
25373 {
25374
3/4
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 2810 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 987 times.
3797 if(!skippedaframe && (base_scr->tilewarptype[index]!=wtNOWARP))
25375 {
25376 987 FFCore.warpScriptCheck();
25377 987 draw_screen();
25378 987 advanceframe(true);
25379 987 }
25380
25381 3797 sdir = dir;
25382 3797 dowarp(scr, 0, index, warpsfx2);
25383 }
25384 14247884 }
25385
25386 126 int32_t selectWlevel(int32_t d)
25387 {
25388
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(TriforceCount()==0)
25389 return 0;
25390
25391 126 word l = game->get_wlevel();
25392
25393 126 do
25394 {
25395
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
199 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
25396 break;
25397
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 80 times.
199 else if(d<0)
25398
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 16 times.
80 l = (l==0) ? 7 : l-1;
25399 else
25400
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 103 times.
119 l = (l==7) ? 0 : l+1;
25401
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 126 times.
199 }
25402 199 while(!(game->lvlitems[l+1] & liTRIFORCE));
25403
25404 126 game->set_wlevel(l);
25405 126 return l;
25406 126 }
25407
25408 // Would someone tell the Dodongos to shut their yaps?!
25409 27954 void kill_enemy_sfx()
25410 {
25411
2/2
✓ Branch 0 taken 27954 times.
✓ Branch 1 taken 55326 times.
83280 for(int32_t i=0; i<guys.Count(); i++)
25412 {
25413
2/2
✓ Branch 0 taken 20640 times.
✓ Branch 1 taken 34686 times.
55326 if(((enemy*)guys.spr(i))->bgsfx)
25414 34686 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
25415 55326 }
25416
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
25417
2/2
✓ Branch 0 taken 27938 times.
✓ Branch 1 taken 16 times.
27954 if(hero_scr->room==rGANON)
25418 16 stop_sfx(WAV_ROAR);
25419 27954 }
25420
25421 3271 bool HeroClass::HasHeavyBoots()
25422 {
25423
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 837376 times.
840647 for ( int32_t q = 0; q < MAXITEMS; ++q )
25424 {
25425
3/6
✓ Branch 0 taken 68711 times.
✓ Branch 1 taken 768665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68711 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
837376 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&item_flag2) ) return true;
25426 837376 }
25427 3271 return false;
25428 3271 }
25429
25430 7348 bool HeroClass::dowarp(const mapscr* scr, int32_t type, int32_t index, int32_t warpsfx)
25431 {
25432
1/2
✓ Branch 0 taken 7348 times.
✗ Branch 1 not taken.
7348 if (!scr) scr = hero_scr;
25433
25434 7348 byte reposition_sword_postwarp = 0;
25435
1/2
✓ Branch 0 taken 7348 times.
✗ Branch 1 not taken.
7348 if (index < 0)
25436 {
25437 return false;
25438 }
25439 7348 is_warping = true;
25440
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 7348 times.
8117 for (int32_t q = 0; q < Lwpns.Count(); ++q)
25441 {
25442 769 weapon* swd = NULL;
25443 769 swd = (weapon*)Lwpns.spr(q);
25444
2/2
✓ Branch 0 taken 699 times.
✓ Branch 1 taken 70 times.
769 if (swd->id == (attack == wSword ? wSword : wWand))
25445 {
25446 70 Lwpns.del(q);
25447 70 }
25448 769 }
25449
25450 7348 attackclk = charging = spins = tapping = 0;
25451 7348 attack = none;
25452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7348 times.
7348 if (warp_sound > 0) warpsfx = warp_sound;
25453 7348 warp_sound = 0;
25454 7348 word wdmap = 0;
25455 7348 byte wscr = 0, wtype = 0, t = 0;
25456 7348 bool overlay = false;
25457 7348 t = (cur_screen < 128) ? 0 : 1;
25458 7348 int32_t wrindex = 0;
25459 7348 bool wasSideview = isSideViewGravity(t);
25460
25461 // Either the current screen, or if in a 0x80 room the screen player came from.
25462
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 6956 times.
7348 const mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : scr;
25463
25464 // Drawing commands probably shouldn't carry over...
25465
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 6956 times.
7348 if (!get_qr(qr_SCRIPTDRAWSINWARPS))
25466 6956 script_drawing_commands.Clear();
25467
25468
2/2
✓ Branch 0 taken 7287 times.
✓ Branch 1 taken 61 times.
7348 if (replay_version_check(35))
25469 {
25470 // TODO: Would be better to remove a bit later, after fading out the current screen. For now, do this here.
25471 // https://github.com/ZQuestClassic/ZQuestClassic/pull/1017#discussion_r1828880117
25472 61 reset_ladder();
25473 61 }
25474
4/6
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 3841 times.
✓ Branch 2 taken 2990 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7348 switch(type)
25475 {
25476 case 0: // tile warp
25477 3841 wtype = base_scr->tilewarptype[index];
25478 3841 wdmap = base_scr->tilewarpdmap[index];
25479 3841 wscr = base_scr->tilewarpscr[index];
25480 3841 overlay = get_bit(&base_scr->tilewarpoverlayflags,index)?1:0;
25481 3841 wrindex=(scr->warpreturnc>>(index*2))&3;
25482 3841 break;
25483
25484 case 1: // side warp
25485 2990 wtype = base_scr->sidewarptype[index];
25486 2990 wdmap = base_scr->sidewarpdmap[index];
25487 2990 wscr = base_scr->sidewarpscr[index];
25488 2990 overlay = get_bit(&base_scr->sidewarpoverlayflags,index)?1:0;
25489 2990 wrindex=(scr->warpreturnc>>(8+(index*2)))&3;
25490 2990 break;
25491
25492 case 2: // whistle warp
25493 {
25494 125 wtype = wtWHISTLE;
25495
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
25496 125 int32_t level=0;
25497
25498
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(blowcnt==0)
25499 level = selectWlevel(0);
25500 else
25501 {
25502
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 125 times.
251 for(int32_t i=0; i<abs(blowcnt); i++)
25503 126 level = selectWlevel(blowcnt);
25504 }
25505
25506
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
125 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
25507 {
25508 2 level %= QMisc.warp[wind].size;
25509 2 game->set_wlevel(level);
25510 2 }
25511
25512 125 wdmap = QMisc.warp[wind].dmap[level];
25513 125 wscr = QMisc.warp[wind].scr[level];
25514 }
25515 125 break;
25516
25517 case 3:
25518 wtype = wtIWARP;
25519 wdmap = cheat_goto_dmap;
25520 wscr = cheat_goto_screen;
25521 break;
25522
25523 case 4:
25524 wtype = wtIWARP;
25525 wdmap = cur_dmap;
25526 wscr = home_screen-DMaps[cur_dmap].xoff;
25527 break;
25528 }
25529
25530 7348 bool intradmap = (wdmap == cur_dmap);
25531 7348 int32_t olddmap = cur_dmap;
25532 7348 rehydratelake(type!=wtSCROLL);
25533 7348 bool updatemusic = FFCore.can_dmap_change_music(wdmap);
25534 7348 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
25535 7348 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
25536
25537
7/8
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 1636 times.
✓ Branch 5 taken 893 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 151 times.
7348 switch(wtype)
25538 {
25539 case wtCAVE:
25540 {
25541 // cave/item room
25542 585 ALLOFF();
25543
25544
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 154 times.
585 if(DMaps[cur_dmap].flags&dmfCAVES) // cave
25545 {
25546
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
431 if (updatemusic || !musicnocut || !get_qr(qr_SCREEN80_OWN_MUSIC))
25547 431 music_stop();
25548 431 kill_sfx();
25549
25550 431 int destscr = 0x80;
25551
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 369 times.
431 if(scr->room==rWARP)
25552 {
25553 62 destscr=0x81;
25554 62 specialcave = STAIRCAVE;
25555 62 }
25556 369 else specialcave = GUYCAVE;
25557
25558 //lighting(2,dir);
25559 431 lighting(false, true);
25560 431 loadlvlpal(10);
25561
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 65 times.
797 bool b2 = COOLSCROLL&&
25562
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
366 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
25563
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
25564
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
25565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
25566 431 blackscr(30,b2?false:true);
25567 431 loadscr(wdmap, destscr, up, false);
25568 431 scr = hero_scr;
25569 //preloaded freeform combos
25570 431 ffscript_engine(true);
25571 431 dir=up;
25572 431 x=112;
25573 431 y=160;
25574
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(didpit)
25575 {
25576 didpit=false;
25577 x=pitx;
25578 y=pity;
25579 }
25580
25581 431 reset_hookshot();
25582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(reposition_sword_postwarp)
25583 {
25584 weapon *swd=NULL;
25585 for(int32_t i=0; i<Lwpns.Count(); i++)
25586 {
25587 swd = (weapon*)Lwpns.spr(i);
25588
25589 if(swd->id == (attack==wSword ? wSword : wWand))
25590 {
25591 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25592 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25593 positionSword(swd,item_id);
25594 break;
25595 }
25596 }
25597 }
25598 431 stepforward(diagonalMovement?5:6, false);
25599 431 }
25600 else // item room
25601 {
25602 154 specialcave = ITEMCELLAR;
25603 154 kill_sfx();
25604 154 draw_screen(false);
25605
25606 //unless the room is already dark, fade to black
25607
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 153 times.
154 if (!get_qr(qr_NEW_DARKROOM))
25608 {
25609
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 if(!darkroom)
25610 {
25611 152 darkroom = true;
25612 152 fade(DMaps[cur_dmap].color,true,false);
25613 152 }
25614 153 }
25615 else
25616 1 fade(DMaps[cur_dmap].color, true, false);
25617
25618 154 blackscr(30,true);
25619
25620 154 bool no_x80_dir = true; // TODO: is this necessary?
25621 154 loadscr(wdmap, 0x80, down, false, no_x80_dir);
25622 154 scr = hero_scr;
25623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=1; }
25624 154 draw_screen(false);
25625 154 fade(0xB,true,true);
25626 154 darkroom = false;
25627 154 dir=down;
25628 154 x=48;
25629 154 y=0;
25630
25631 // is this didpit check necessary?
25632
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 1 times.
154 if(didpit)
25633 {
25634 1 didpit=false;
25635 1 x=pitx;
25636 1 y=pity;
25637 1 }
25638
25639 154 reset_hookshot();
25640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(reposition_sword_postwarp)
25641 {
25642 weapon *swd=NULL;
25643 for(int32_t i=0; i<Lwpns.Count(); i++)
25644 {
25645 swd = (weapon*)Lwpns.spr(i);
25646
25647 if(swd->id == (attack==wSword ? wSword : wWand))
25648 {
25649 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25650 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25651 positionSword(swd,item_id);
25652 break;
25653 }
25654 }
25655 }
25656 154 lighting(false, true);
25657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=0; }
25658 154 stepforward(diagonalMovement?16:18, false);
25659 }
25660
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
585 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
25661 {
25662 playLevelMusic();
25663 if (musicrevert)
25664 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25665 }
25666 585 break;
25667 }
25668
25669 case wtPASS: // passageway
25670 {
25671 // some draw_screen code (the passive subscreen compass dot) depends
25672 // on cur_screen being set before initiating the screen wipes for a warp.
25673 // Without this the compass dot would remain drawn while warping.
25674 // This is better, but for now this code keeps the rendering equivalent to before
25675 // z3 refactor.
25676 // demosp253.zplay and first_quest_layered.zplay showcases this behavior.
25677 // TODO(replays): remove in future bulk replay update.
25678 322 currscr_for_passive_subscr = 0x81;
25679
25680 322 kill_sfx();
25681 322 ALLOFF();
25682 //play sound
25683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25684 322 specialcave = PASSAGEWAY;
25685 322 byte warp_screen_2 = wscr + DMaps[wdmap].xoff;
25686 322 draw_screen(false);
25687
25688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(!get_qr(qr_NEW_DARKROOM))
25689 {
25690
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 314 times.
322 if(!darkroom)
25691 314 fade(DMaps[cur_dmap].color,true,false);
25692
25693 322 darkroom=true;
25694 322 }
25695 else
25696 fade(DMaps[cur_dmap].color,true,false);
25697 322 blackscr(30,true);
25698 322 bool no_x80_dir = true;
25699 322 loadscr(wdmap, 0x81, down, false, no_x80_dir);
25700 322 scr = hero_scr;
25701 //preloaded freeform combos
25702 322 ffscript_engine(true);
25703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=1; }
25704 322 draw_screen(false);
25705 322 lighting(false, true);
25706
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if (get_qr(qr_NEW_DARKROOM))
25707 fade(0xB, false, true);
25708 322 dir=down;
25709 322 x=48;
25710
25711
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 174 times.
322 if((home_screen&15) > (warp_screen_2&15))
25712 {
25713 174 x=192;
25714 174 }
25715
25716
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 12 times.
322 if((home_screen&15) == (warp_screen_2&15))
25717 {
25718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if((cur_screen>>4) > (warp_screen_2>>4))
25719 {
25720 12 x=192;
25721 12 }
25722 12 }
25723
25724 // is this didpit check necessary?
25725
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(didpit)
25726 {
25727 didpit=false;
25728 x=pitx;
25729 y=pity;
25730 }
25731
25732 322 y=0;
25733 322 set_respawn_point();
25734 322 trySideviewLadder();
25735 322 reset_hookshot();
25736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(reposition_sword_postwarp)
25737 {
25738 weapon *swd=NULL;
25739 for(int32_t i=0; i<Lwpns.Count(); i++)
25740 {
25741 swd = (weapon*)Lwpns.spr(i);
25742
25743 if(swd->id == (attack==wSword ? wSword : wWand))
25744 {
25745 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25746 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25747 positionSword(swd,item_id);
25748 break;
25749 }
25750 }
25751 }
25752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=0; }
25753 322 stepforward(diagonalMovement?16:18, false);
25754 322 newscr_clk=frame;
25755 322 activated_timed_warp=false;
25756 322 stepoutindex=index;
25757 322 stepoutscreen = warp_screen_2;
25758 322 stepoutdmap = wdmap;
25759 322 stepoutwr=wrindex;
25760
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
322 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
25761 {
25762 playLevelMusic();
25763 if (musicrevert)
25764 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25765 }
25766 }
25767 322 break;
25768
25769 case wtEXIT: // entrance/exit
25770 {
25771 1636 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
25772 1636 ALLOFF();
25773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1636 if(updatemusic||!musicnocut)
25774 1636 music_stop();
25775 1636 kill_sfx();
25776 1636 blackscr(30,false);
25777 1636 bool changedlevel = false;
25778 1636 bool changeddmap = false;
25779
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(cur_dmap != wdmap)
25780 {
25781 1633 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25782 1633 changeddmap = true;
25783 1633 }
25784
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(dlevel != DMaps[wdmap].level)
25785 {
25786 1374 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25787 1374 changedlevel = true;
25788 1374 }
25789 1636 dlevel = DMaps[wdmap].level;
25790 1636 cur_dmap = wdmap;
25791
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(changeddmap)
25792 {
25793 1633 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25794 1633 }
25795
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(changedlevel)
25796 {
25797 1374 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25798 1374 }
25799
25800 1636 cur_map=DMaps[cur_dmap].map;
25801 1636 init_dmap();
25802 1636 update_subscreens(wdmap);
25803 1636 loadfullpal();
25804 1636 ringcolor(false);
25805 1636 loadlvlpal(DMaps[cur_dmap].color);
25806 1636 int destscr = wscr + DMaps[cur_dmap].xoff;
25807 1636 loadscr(cur_dmap, destscr, -1, overlay);
25808 1636 scr = hero_scr;
25809
25810
4/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1580 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 10 times.
1636 if (is_dark(scr) && !get_qr(qr_NEW_DARKROOM))
25811 {
25812
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(get_qr(qr_FADE))
25813 {
25814 7 interpolatedfade();
25815 7 }
25816 else
25817 {
25818 3 loadfadepal((DMaps[cur_dmap].color)*pdLEVEL+poFADE3);
25819 }
25820
25821 10 darkroom=naturaldark=true;
25822 10 }
25823 else
25824 {
25825 1626 darkroom=naturaldark=false;
25826 }
25827
25828 int32_t wrx,wry;
25829
25830
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 981 times.
1636 if(get_qr(qr_NOARRIVALPOINT))
25831 {
25832 655 wrx=scr->warpreturnx[0];
25833 655 wry=scr->warpreturny[0];
25834 655 }
25835 else
25836 {
25837 981 wrx=scr->warparrivalx;
25838 981 wry=scr->warparrivaly;
25839 }
25840
25841
6/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1545 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1573 times.
1636 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!(scr->flags6&fNOCONTINUEHERE)))
25842 {
25843
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 460 times.
1573 if(dlevel)
25844 {
25845 1113 lastentrance = cur_screen;
25846 1113 }
25847 else
25848 {
25849 460 lastentrance = DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff;
25850 }
25851
25852 1573 lastentrance_dmap = wdmap;
25853 1573 }
25854
25855
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25856 {
25857
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 554 times.
1113 if(get_qr(qr_NOARRIVALPOINT))
25858 {
25859 559 x=scr->warpreturnx[wrindex];
25860 559 y=scr->warpreturny[wrindex];
25861 559 }
25862 else
25863 {
25864 554 x=scr->warparrivalx;
25865 554 y=scr->warparrivaly;
25866 }
25867 1113 }
25868 else
25869 {
25870 523 x=scr->warpreturnx[wrindex];
25871 523 y=scr->warpreturny[wrindex];
25872 }
25873
25874
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 9 times.
1636 if(didpit)
25875 {
25876 9 didpit=false;
25877 9 x=pitx;
25878 9 y=pity;
25879 9 }
25880
25881 1636 dir=down;
25882
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1608 times.
1636 if(x==0) dir=right;
25883
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1613 times.
1636 if(x==240) dir=left;
25884
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1598 times.
1636 if(y==0) dir=down;
25885
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 1008 times.
1636 if(y==160) dir=up;
25886
25887 1636 x += region_scr_dx * 256;
25888 1636 y += region_scr_dy * 176;
25889 1636 update_viewport();
25890
25891
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
25892 {
25893 // reset enemy kill counts
25894
2/2
✓ Branch 0 taken 142464 times.
✓ Branch 1 taken 1113 times.
143577 for(int32_t i=0; i<128; i++)
25895 {
25896 142464 int mi = mapind(cur_map, i);
25897 142464 game->guys[mi] = 0;
25898 142464 game->maps[mi] &= ~mTMPNORET;
25899 142464 }
25900 1113 }
25901
25902 1636 markBmap(dir^1, hero_screen);
25903 //preloaded freeform combos
25904 1636 ffscript_engine(true);
25905
25906 1636 reset_hookshot();
25907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
1636 if(reposition_sword_postwarp)
25908 {
25909 weapon *swd=NULL;
25910 for(int32_t i=0; i<Lwpns.Count(); i++)
25911 {
25912 swd = (weapon*)Lwpns.spr(i);
25913
25914 if(swd->id == (attack==wSword ? wSword : wWand))
25915 {
25916 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25917 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25918 positionSword(swd,item_id);
25919 break;
25920 }
25921 }
25922 }
25923
25924
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1163 times.
1636 if(isdungeon())
25925 {
25926 473 openscreen();
25927
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 374 times.
473 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
25928 374 stepforward(diagonalMovement?11:12, false);
25929 else
25930 // Didn't walk as far pre-1.93, and some quests depend on that
25931 99 stepforward(8, false);
25932 473 }
25933 else
25934 {
25935
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 996 times.
1163 if(!COOLSCROLL)
25936 167 openscreen();
25937
25938 1163 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
25939 1163 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25940 1163 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
25941
25942
10/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1004 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 977 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 52 times.
1163 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25943 {
25944 202 reset_pal_cycling();
25945 202 walkup(COOLSCROLL);
25946 202 }
25947
10/10
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 951 times.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 74 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 881 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 25 times.
1029 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25948 {
25949 153 reset_pal_cycling();
25950 153 walkdown2(COOLSCROLL);
25951 153 }
25952
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 52 times.
906 else if(COOLSCROLL)
25953 {
25954 852 openscreen();
25955 852 }
25956 }
25957
25958 1678 show_subscreen_life=true;
25959 1678 show_subscreen_numbers=true;
25960
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 43 times.
1678 if (updatemusic || !musicnocut)
25961 {
25962 1721 playLevelMusic();
25963
1/2
✓ Branch 0 taken 1635 times.
✗ Branch 1 not taken.
1721 if (musicrevert)
25964 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25965 1635 }
25966 1678 currcset=DMaps[cur_dmap].color;
25967 1678 dointro();
25968 1678 set_respawn_point();
25969 1678 trySideviewLadder();
25970
25971
2/2
✓ Branch 0 taken 9810 times.
✓ Branch 1 taken 1678 times.
11488 for(int32_t i=0; i<6; i++)
25972 9810 visited[i]=-1;
25973
25974 1678 break;
25975 }
25976
25977 case wtSCROLL: // scrolling warp
25978 {
25979 893 int32_t c = DMaps[cur_dmap].color;
25980 893 scrolling_dmap = cur_dmap;
25981 893 scrolling_map = cur_map;
25982 893 cur_map = DMaps[wdmap].map;
25983 893 update_subscreens(wdmap);
25984
25985 893 dlevel = DMaps[wdmap].level;
25986 //check if Hero has the map for the new location before updating the subscreen. ? -Z
25987 //This works only in one direction, if Hero had a map, to not having one.
25988 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
25989 893 update_subscreens(wdmap);
25990
25991 /*if ( has_item(itype_map, dlevel) )
25992 {
25993 //Blank the map during an intra-dmap scrolling warp.
25994 dlevel = -1; //a hack for the minimap. This works!! -Z
25995 }*/
25996
25997 // fix the scrolling direction, if it was a tile or instant warp
25998
2/4
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 893 times.
893 if(type==0 || type>=3)
25999 {
26000 sdir = dir;
26001 }
26002
26003 893 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
26004 893 scr = hero_scr;
26005
26006 893 reset_hookshot();
26007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(reposition_sword_postwarp)
26008 {
26009 weapon *swd=NULL;
26010 for(int32_t i=0; i<Lwpns.Count(); i++)
26011 {
26012 swd = (weapon*)Lwpns.spr(i);
26013
26014 if(swd->id == (attack==wSword ? wSword : wWand))
26015 {
26016 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26017 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26018 positionSword(swd,item_id);
26019 break;
26020 }
26021 }
26022 }
26023
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 786 times.
893 if(!intradmap)
26024 {
26025 786 init_dmap();
26026
26027 int32_t wrx,wry;
26028
26029
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 338 times.
786 if(get_qr(qr_NOARRIVALPOINT))
26030 {
26031 448 wrx=hero_scr->warpreturnx[0];
26032 448 wry=hero_scr->warpreturny[0];
26033 448 }
26034 else
26035 {
26036 338 wrx=hero_scr->warparrivalx;
26037 338 wry=hero_scr->warparrivaly;
26038 }
26039
26040
8/8
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 430 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 504 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 270 times.
786 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(scr->flags6&fNOCONTINUEHERE)))
26041 {
26042
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 195 times.
270 if(dlevel)
26043 {
26044 75 lastentrance = cur_screen;
26045 75 }
26046 else
26047 {
26048 195 lastentrance = DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff;
26049 }
26050
26051 270 lastentrance_dmap = wdmap;
26052 270 }
26053 786 }
26054
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 491 times.
893 if(DMaps[cur_dmap].color != c)
26055 {
26056 491 lighting(false, true);
26057 491 }
26058
26059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if (updatemusic)
26060 {
26061 893 playLevelMusic();
26062
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if (musicrevert)
26063 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26064 893 }
26065 893 currcset=DMaps[cur_dmap].color;
26066 893 dointro();
26067 }
26068 893 break;
26069
26070 case wtWHISTLE: // whistle warp
26071 {
26072 125 scrolling_dmap = cur_dmap;
26073 125 scrolling_map = cur_map;
26074 125 cur_map = DMaps[wdmap].map;
26075 125 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
26076 125 scr = hero_scr;
26077 125 reset_hookshot();
26078 125 cur_dmap=wdmap;
26079 125 dlevel=DMaps[cur_dmap].level;
26080 125 lighting(false, true);
26081 125 init_dmap();
26082
26083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if (updatemusic)
26084 {
26085 125 playLevelMusic();
26086
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if (musicrevert)
26087 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26088 125 }
26089 125 currcset=DMaps[cur_dmap].color;
26090 125 dointro();
26091 125 action=inwind; FFCore.setHeroAction(inwind);
26092 int32_t wry;
26093
26094
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
26095 42 wry=hero_scr->warpreturny[0];
26096 83 else wry=hero_scr->warparrivaly;
26097
26098 int32_t wrx;
26099
26100
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
26101 42 wrx=hero_scr->warpreturnx[0];
26102 83 else wrx=hero_scr->warparrivalx;
26103
26104 125 wrx += region_scr_dx * 256;
26105 125 wry += region_scr_dy * 176;
26106
26107 125 calculate_viewport(viewport, cur_dmap, cur_screen, world_w, world_h, wrx + Hero.txsz*16/2, wry + Hero.tysz*16/2);
26108
26109
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 10 times.
125 zfix whistle_x = index==left?viewport.right()-16:index==right?viewport.left():wrx;
26110
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 6 times.
125 zfix whistle_y = index==down?viewport.top():index==up?viewport.bottom()-16:wry;
26111
26112
3/6
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✗ Branch 5 not taken.
250 auto wind = new weapon(whistle_x,whistle_y,
26113
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1);
26114 125 wind->screen_spawned = hero_scr->screen;
26115 125 Lwpns.add(wind);
26116 125 whirlwind=255;
26117 125 whistleitem=-1;
26118 }
26119 125 break;
26120
26121 case wtIWARP:
26122 case wtIWARPBLK:
26123 case wtIWARPOPEN:
26124 case wtIWARPZAP:
26125 case wtIWARPWAVE: // insta-warps
26126 {
26127 3636 bool old_192 = false;
26128
2/2
✓ Branch 0 taken 3592 times.
✓ Branch 1 taken 44 times.
3636 if (get_qr(qr_192b163_WARP))
26129 {
26130
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( wtype == wtIWARPWAVE )
26131 {
26132 wtype = wtIWARPWAVE;
26133 old_192 = true;
26134 }
26135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( old_192 )
26136 {
26137 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
26138 didpit=false;
26139 update_subscreens();
26140 warp_sound = 0;
26141 is_warping = false;
26142 return false;
26143 }
26144 44 }
26145 //for determining whether to exit cave
26146 3636 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26147 3636 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26148 3636 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26149
26150
8/8
✓ Branch 0 taken 3231 times.
✓ Branch 1 taken 405 times.
✓ Branch 2 taken 67 times.
✓ Branch 3 taken 3164 times.
✓ Branch 4 taken 3231 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 95 times.
✓ Branch 7 taken 3136 times.
7056 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26151
8/8
✓ Branch 0 taken 3209 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 3139 times.
✓ Branch 4 taken 69 times.
✓ Branch 5 taken 3208 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 58 times.
3231 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26152
26153 4054 bool kill_action = !(scr->flags3&fIWARP_SPRITE_CARRYOVER);
26154
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3241 times.
4054 if(kill_action)
26155 {
26156 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26157 3241 bool wasswimming = (action == swimming);
26158 3241 int32_t olddiveclk = diveclk;
26159 3241 ALLOFF();
26160
26161
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 36 times.
3241 if(wasswimming)
26162 {
26163 36 Hero.SetSwim();
26164 36 diveclk = olddiveclk;
26165 36 }
26166
26167 3241 kill_sfx();
26168 3241 }
26169 //play sound
26170
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 95 times.
3244 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26171
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2654 times.
3244 if(wtype==wtIWARPZAP)
26172 {
26173 590 zapout();
26174 590 }
26175
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 2431 times.
2654 else if(wtype==wtIWARPWAVE)
26176 {
26177 //only draw Hero if he's not in a cave -DD
26178 223 wavyout(!cavewarp);
26179 223 }
26180
2/2
✓ Branch 0 taken 1509 times.
✓ Branch 1 taken 922 times.
2431 else if(wtype!=wtIWARP)
26181 {
26182
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 627 times.
922 bool b2 = COOLSCROLL&&cavewarp;
26183 922 blackscr(30,b2?false:true);
26184 922 }
26185
26186 3244 int32_t c = DMaps[cur_dmap].color;
26187 3244 bool changedlevel = false;
26188 3244 bool changeddmap = false;
26189
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 1728 times.
3244 if(cur_dmap != wdmap)
26190 {
26191 1728 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26192 1728 changeddmap = true;
26193 1728 }
26194
2/2
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 590 times.
3244 if(dlevel != DMaps[wdmap].level)
26195 {
26196 590 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26197 590 changedlevel = true;
26198 590 }
26199 3244 dlevel = DMaps[wdmap].level;
26200 3244 cur_dmap = wdmap;
26201
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 1728 times.
3244 if(changeddmap)
26202 {
26203 1728 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26204 1728 }
26205
2/2
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 590 times.
3244 if(changedlevel)
26206 {
26207 590 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26208 590 }
26209
26210 3244 cur_map = DMaps[cur_dmap].map;
26211 3244 init_dmap();
26212 3244 update_subscreens(wdmap);
26213
26214 3244 ringcolor(false);
26215
26216
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 883 times.
3244 if(DMaps[cur_dmap].color != c)
26217 883 loadlvlpal(DMaps[cur_dmap].color);
26218
26219 3244 int prevscr = cur_screen;
26220 3244 loadscr(cur_dmap, wscr + DMaps[cur_dmap].xoff, -1, overlay);
26221 3244 scr = hero_scr;
26222 3244 lightingInstant(); // Also sets naturaldark
26223
26224 // In the case where we did not call ALLOFF, preserve the "enemies have spawned"
26225 // state for the new screen.
26226
2/2
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 3 times.
3244 if (!kill_action)
26227 {
26228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_screen_state(prevscr).loaded_enemies)
26229 3 get_screen_state(cur_screen).loaded_enemies = true;
26230 3 }
26231
26232 3244 x = hero_scr->warpreturnx[wrindex];
26233 3244 y = hero_scr->warpreturny[wrindex];
26234
26235
2/2
✓ Branch 0 taken 1982 times.
✓ Branch 1 taken 1262 times.
3244 if(didpit)
26236 {
26237 1262 didpit=false;
26238 1262 x=pitx;
26239 1262 y=pity;
26240 1262 }
26241
26242 3244 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26243 3244 type2 = combobuf[MAPCOMBO(x,y)].type;
26244 3244 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26245
26246
2/2
✓ Branch 0 taken 3153 times.
✓ Branch 1 taken 91 times.
3244 if(x==0) dir=right;
26247
26248
2/2
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 4 times.
3244 if(x==240) dir=left;
26249
26250
2/2
✓ Branch 0 taken 3187 times.
✓ Branch 1 taken 57 times.
3244 if(y==0) dir=down;
26251
26252
2/2
✓ Branch 0 taken 3176 times.
✓ Branch 1 taken 68 times.
3244 if(y==160) dir=up;
26253
26254 3244 x += region_scr_dx * 256;
26255 3244 y += region_scr_dy * 176;
26256 3244 update_viewport();
26257
26258 3244 markBmap(dir^1, hero_screen);
26259
26260 3244 int32_t checkwater = iswaterex_z3(MAPCOMBO(x,y+8), -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
26261
26262
10/16
✓ Branch 0 taken 3215 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 29 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 3215 times.
3273 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,STANDING_Z_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
26263 {
26264 29 hopclk=0xFF;
26265 29 SetSwim();
26266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (!IsSideSwim()) attackclk = charging = spins = 0;
26267 29 }
26268 else
26269 {
26270 3215 action = none; FFCore.setHeroAction(none);
26271 }
26272 //preloaded freeform combos
26273 3244 ffscript_engine(true);
26274
26275 3244 putscr(hero_scr, scrollbuf, 0, 0);
26276 3244 putscrdoors(hero_scr, scrollbuf, 0, 0);
26277
26278
10/10
✓ Branch 0 taken 3232 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 67 times.
✓ Branch 3 taken 3165 times.
✓ Branch 4 taken 3232 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 3152 times.
✓ Branch 8 taken 174 times.
✓ Branch 9 taken 254 times.
3244 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26279 {
26280 320 reset_pal_cycling();
26281 320 putscr(hero_scr, scrollbuf, 0, 0);
26282 320 putscrdoors(hero_scr, scrollbuf, 0, 0);
26283 320 walkup(COOLSCROLL);
26284 320 }
26285
9/10
✓ Branch 0 taken 3232 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 3142 times.
✓ Branch 4 taken 3229 times.
✓ Branch 5 taken 87 times.
✓ Branch 6 taken 76 times.
✓ Branch 7 taken 3153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 76 times.
3406 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26286 {
26287 351 reset_pal_cycling();
26288 351 putscr(hero_scr, scrollbuf, 0, 0);
26289 351 putscrdoors(hero_scr, scrollbuf, 0, 0);
26290 351 walkdown2(COOLSCROLL);
26291 351 }
26292
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 2641 times.
3229 else if(wtype==wtIWARPZAP)
26293 {
26294 588 zapin();
26295 588 }
26296
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 2421 times.
2641 else if(wtype==wtIWARPWAVE)
26297 {
26298 220 wavyin();
26299 220 }
26300
2/2
✓ Branch 0 taken 2283 times.
✓ Branch 1 taken 138 times.
2421 else if(wtype==wtIWARPOPEN)
26301 {
26302 138 openscreen();
26303 138 }
26304
1/2
✓ Branch 0 taken 3552 times.
✗ Branch 1 not taken.
3552 if(reposition_sword_postwarp)
26305 {
26306 weapon *swd=NULL;
26307 for(int32_t i=0; i<Lwpns.Count(); i++)
26308 {
26309 swd = (weapon*)Lwpns.spr(i);
26310
26311 if(swd->id == (attack==wSword ? wSword : wWand))
26312 {
26313 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26314 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26315 positionSword(swd,item_id);
26316 break;
26317 }
26318 }
26319 }
26320 3552 show_subscreen_life=true;
26321 3552 show_subscreen_numbers=true;
26322
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 3244 times.
3552 if (updatemusic)
26323 {
26324 3244 playLevelMusic();
26325
1/2
✓ Branch 0 taken 3244 times.
✗ Branch 1 not taken.
3244 if (musicrevert)
26326 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26327 3244 }
26328 3552 currcset=DMaps[cur_dmap].color;
26329 3552 dointro();
26330 3552 set_respawn_point();
26331 3552 trySideviewLadder();
26332 }
26333 3552 break;
26334
26335
26336 case wtNOWARP:
26337 {
26338 151 bool old_192 = false;
26339
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if (get_qr(qr_192b163_WARP))
26340 {
26341 wtype = wtIWARPWAVE;
26342 old_192 = true;
26343 }
26344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if ( old_192 )
26345 {
26346 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
26347 //for determining whether to exit cave
26348 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26349 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26350 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26351
26352 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26353 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26354
26355 if(!(scr->flags3&fIWARP_SPRITE_CARRYOVER))
26356 {
26357 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26358 bool wasswimming = (action == swimming);
26359 int32_t olddiveclk = diveclk;
26360 ALLOFF();
26361
26362 if(wasswimming)
26363 {
26364 Hero.SetSwim();
26365 diveclk = olddiveclk;
26366 }
26367
26368 kill_sfx();
26369 }
26370 //play sound
26371 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
26372 if(wtype==wtIWARPZAP)
26373 {
26374 zapout();
26375 }
26376 else if(wtype==wtIWARPWAVE)
26377 {
26378 //only draw Hero if he's not in a cave -DD
26379 wavyout(!cavewarp);
26380 }
26381 else if(wtype!=wtIWARP)
26382 {
26383 bool b2 = COOLSCROLL&&cavewarp;
26384 blackscr(30,b2?false:true);
26385 }
26386
26387 int32_t c = DMaps[cur_dmap].color;
26388 bool changedlevel = false;
26389 bool changeddmap = false;
26390 if(cur_dmap != wdmap)
26391 {
26392 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26393 changeddmap = true;
26394 }
26395 if(dlevel != DMaps[wdmap].level)
26396 {
26397 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26398 changedlevel = true;
26399 }
26400 dlevel = DMaps[wdmap].level;
26401 cur_dmap = wdmap;
26402 if(changeddmap)
26403 {
26404 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26405 }
26406 if(changedlevel)
26407 {
26408 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26409 }
26410 cur_map = DMaps[cur_dmap].map;
26411 init_dmap();
26412 update_subscreens(wdmap);
26413
26414 ringcolor(false);
26415
26416 if(DMaps[cur_dmap].color != c)
26417 loadlvlpal(DMaps[cur_dmap].color);
26418
26419 loadscr(cur_dmap, wscr + DMaps[cur_dmap].xoff, -1, overlay);
26420 scr = hero_scr;
26421 lightingInstant(); // Also sets naturaldark
26422
26423 x = hero_scr->warpreturnx[wrindex];
26424 y = hero_scr->warpreturny[wrindex];
26425
26426 if(didpit)
26427 {
26428 didpit=false;
26429 x=pitx;
26430 y=pity;
26431 }
26432
26433 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26434 type2 = combobuf[MAPCOMBO(x,y)].type;
26435 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26436
26437 if(x==0) dir=right;
26438
26439 if(x==240) dir=left;
26440
26441 if(y==0) dir=down;
26442
26443 if(y==160) dir=up;
26444
26445 x += region_scr_dx * 256;
26446 y += region_scr_dy * 176;
26447 update_viewport();
26448
26449 markBmap(dir^1, hero_screen);
26450
26451 if(iswaterex_z3(MAPCOMBO(x,y+8), -1, x,y+8) && _walkflag(x,y+8,0,STANDING_Z_STATE) && current_item(itype_flippers))
26452 {
26453 hopclk=0xFF;
26454 SetSwim();
26455 if (!IsSideSwim()) attackclk = charging = spins = 0;
26456 }
26457 else
26458 {
26459 action = none;
26460 FFCore.setHeroAction(none);
26461 }
26462 //preloaded freeform combos
26463 ffscript_engine(true);
26464
26465 putscr(hero_scr, scrollbuf, 0, 0);
26466 putscrdoors(hero_scr, scrollbuf, 0, 0);
26467
26468 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26469 {
26470 reset_pal_cycling();
26471 putscr(hero_scr, scrollbuf, 0, 0);
26472 putscrdoors(hero_scr, scrollbuf, 0, 0);
26473 walkup(COOLSCROLL);
26474 }
26475 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26476 {
26477 reset_pal_cycling();
26478 putscr(hero_scr, scrollbuf, 0, 0);
26479 putscrdoors(hero_scr, scrollbuf, 0, 0);
26480 walkdown2(COOLSCROLL);
26481 }
26482 else if(wtype==wtIWARPZAP)
26483 {
26484 zapin();
26485 }
26486 else if(wtype==wtIWARPWAVE)
26487 {
26488 wavyin();
26489 }
26490 else if(wtype==wtIWARPOPEN)
26491 {
26492 openscreen();
26493 }
26494 if(reposition_sword_postwarp)
26495 {
26496 weapon *swd=NULL;
26497 for(int32_t i=0; i<Lwpns.Count(); i++)
26498 {
26499 swd = (weapon*)Lwpns.spr(i);
26500
26501 if(swd->id == (attack==wSword ? wSword : wWand))
26502 {
26503 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26504 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26505 positionSword(swd,item_id);
26506 break;
26507 }
26508 }
26509 }
26510 show_subscreen_life=true;
26511 show_subscreen_numbers=true;
26512 playLevelMusic();
26513 currcset=DMaps[cur_dmap].color;
26514 dointro();
26515 set_respawn_point();
26516 trySideviewLadder();
26517 break;
26518 }
26519 else
26520 {
26521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(reposition_sword_postwarp)
26522 {
26523 weapon *swd=NULL;
26524 for(int32_t i=0; i<Lwpns.Count(); i++)
26525 {
26526 swd = (weapon*)Lwpns.spr(i);
26527
26528 if(swd->id == (attack==wSword ? wSword : wWand))
26529 {
26530 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26531 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26532 positionSword(swd,item_id);
26533 break;
26534 }
26535 }
26536 }
26537 151 didpit=false;
26538 151 update_subscreens();
26539 151 warp_sound = 0;
26540 151 is_warping = false;
26541 151 return false;
26542 }
26543 }
26544 default:
26545 didpit=false;
26546 update_subscreens();
26547 warp_sound = 0;
26548 is_warping = false;
26549 if(reposition_sword_postwarp)
26550 {
26551 weapon *swd=NULL;
26552 for(int32_t i=0; i<Lwpns.Count(); i++)
26553 {
26554 swd = (weapon*)Lwpns.spr(i);
26555
26556 if(swd->id == (attack==wSword ? wSword : wWand))
26557 {
26558 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26559 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26560 positionSword(swd,item_id);
26561 break;
26562 }
26563 }
26564 }
26565 return false;
26566 }
26567
26568 7155 currscr_for_passive_subscr = -1;
26569
26570 // Stop Hero from drowning!
26571
5/6
✓ Branch 0 taken 6804 times.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 6804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 6453 times.
7155 if(action==drowning || action==lavadrowning || action==sidedrowning)
26572 {
26573 702 drownclk=0;
26574 702 drownclk=0;
26575 702 action=none; FFCore.setHeroAction(none);
26576 702 }
26577
26578 6453 int32_t checkwater = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?8:12)), -1, x,y+(bigHitbox?8:12));
26579 // But keep him swimming if he ought to be!
26580 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
26581
10/12
✓ Branch 0 taken 6790 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6738 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 52 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 7088 times.
✓ Branch 11 taken 39 times.
6503 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,STANDING_Z_STATE) || get_qr(qr_DROWN))
26582 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
26583
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
52 && (action!=inwind))
26584 {
26585 39 hopclk=0xFF;
26586 39 SetSwim();
26587 39 }
26588
26589 7127 newscr_clk=frame;
26590 7127 activated_timed_warp=false;
26591 7127 eat_buttons();
26592
26593
2/2
✓ Branch 0 taken 1832 times.
✓ Branch 1 taken 5295 times.
7127 if(wtype!=wtIWARP)
26594 5295 attackclk=0;
26595
26596 7127 didstuff=0;
26597 7127 usecounts.clear();
26598 7127 map_bkgsfx(true);
26599 7127 loadside=dir^1;
26600 7127 whistleclk=-1;
26601
26602
3/4
✓ Branch 0 taken 6798 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 7127 times.
✗ Branch 3 not taken.
7127 if((z>0 || fakez>0) && isSideViewHero())
26603 {
26604 y-=z;
26605 y-=fakez;
26606 fakez=0;
26607 z=0;
26608 }
26609
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 6640 times.
7127 else if(!isSideViewHero())
26610 {
26611 6640 fall=0;
26612 6640 fakefall=0;
26613 6640 }
26614
26615 // If warping between top-down and sideview screens,
26616 // fix enemies that are carried over by Full Screen Warp
26617 7127 const bool tmpscr_is_sideview = isSideViewHero();
26618
26619
4/4
✓ Branch 0 taken 6642 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 6606 times.
✓ Branch 3 taken 36 times.
7127 if(!wasSideview && tmpscr_is_sideview)
26620 {
26621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t i=0; i<guys.Count(); i++)
26622 {
26623 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
26624 {
26625 guys.spr(i)->y -= guys.spr(i)->z;
26626 guys.spr(i)->y -= guys.spr(i)->fakez;
26627 guys.spr(i)->z = 0;
26628 guys.spr(i)->fakez = 0;
26629 }
26630
26631 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26632 guys.spr(i)->yofs += 2;
26633 }
26634 36 }
26635
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 6929 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 34 times.
7091 else if(wasSideview && !tmpscr_is_sideview)
26636 {
26637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 for(int32_t i=0; i<guys.Count(); i++)
26638 {
26639 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
26640 guys.spr(i)->yofs -= 2;
26641 }
26642 34 }
26643
26644
6/6
✓ Branch 0 taken 4404 times.
✓ Branch 1 taken 2723 times.
✓ Branch 2 taken 430 times.
✓ Branch 3 taken 3974 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 179 times.
7127 if((DMaps[cur_dmap].type&dmfCONTINUE) || (cur_dmap==0&&get_qr(qr_DMAP_0_CONTINUE_BUG)))
26645 {
26646
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 1474 times.
3010 if(dlevel)
26647 {
26648 int32_t wrx,wry;
26649
26650
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 820 times.
1346 if(get_qr(qr_NOARRIVALPOINT))
26651 {
26652 526 wrx=origin_scr->warpreturnx[0];
26653 526 wry=origin_scr->warpreturny[0];
26654 526 }
26655 else
26656 {
26657 820 wrx=origin_scr->warparrivalx;
26658 820 wry=origin_scr->warparrivaly;
26659 }
26660
26661
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
1356 if((wtype == wtEXIT)
26662
10/10
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 886 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 4 times.
1346 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))))
26663 {
26664
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 28 times.
440 if(!(wtype==wtSCROLL)||!(get_qr(qr_NOSCROLLCONTINUE)))
26665 {
26666 412 game->set_continue_scrn(home_screen);
26667 412 }
26668
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 15 times.
28 else if(cur_dmap != game->get_continue_dmap())
26669 {
26670 15 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
26671 15 }
26672 440 }
26673 else
26674 {
26675
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 85 times.
906 if(cur_dmap != game->get_continue_dmap())
26676 {
26677 85 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
26678 85 }
26679 }
26680 1346 }
26681 else
26682 {
26683 1474 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
26684 }
26685
26686 2820 game->set_continue_dmap(cur_dmap);
26687 2820 lastentrance_dmap = cur_dmap;
26688 2820 lastentrance = game->get_continue_scrn();
26689 2820 }
26690
26691
1/2
✓ Branch 0 taken 6973 times.
✗ Branch 1 not taken.
6973 if(origin_scr->flags4&fAUTOSAVE)
26692 {
26693 save_game(true,0);
26694 }
26695
26696
2/2
✓ Branch 0 taken 6828 times.
✓ Branch 1 taken 145 times.
6973 if(origin_scr->flags6&fCONTINUEHERE)
26697 {
26698 145 lastentrance_dmap = cur_dmap;
26699 145 lastentrance = home_screen;
26700 145 }
26701
26702 6973 update_subscreens();
26703 6973 verifyBothWeapons();
26704
26705 static const char roomtype_names[rMAX][255] =
26706 {
26707 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
26708 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Level 9 Entrance",
26709 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
26710 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash",
26711 "More Arrows","Take One Item","Bottle Shop"
26712 };
26713
26714
2/2
✓ Branch 0 taken 6388 times.
✓ Branch 1 taken 585 times.
6973 if(wtype==wtCAVE)
26715 {
26716
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 154 times.
585 if(DMaps[cur_dmap].flags&dmfGUYCAVES)
26717 862 Z_eventlog("Entered %s containing %s.\n",DMaps[cur_dmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
26718 431 (char *)roomtype_names[special_warp_return_scr->room]);
26719 else
26720 154 Z_eventlog("Entered %s.",DMaps[cur_dmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
26721 585 }
26722 12776 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", cur_dmap, DMaps[cur_dmap].name,cur_screen,
26723
2/2
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 5897 times.
12285 wtype==wtPASS ? "Passageway" :
26724
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 4262 times.
10159 wtype==wtEXIT ? "Entrance/Exit" :
26725
2/2
✓ Branch 0 taken 893 times.
✓ Branch 1 taken 3369 times.
4262 wtype==wtSCROLL ? "Scrolling Warp" :
26726 3369 wtype==wtWHISTLE ? "Whistle Warp" :
26727 "Insta-Warp");
26728
26729 6973 eventlog_mapflags();
26730
1/2
✓ Branch 0 taken 6973 times.
✗ Branch 1 not taken.
6973 if(reposition_sword_postwarp)
26731 {
26732 weapon *swd=NULL;
26733 for(int32_t i=0; i<Lwpns.Count(); i++)
26734 {
26735 swd = (weapon*)Lwpns.spr(i);
26736
26737 if(swd->id == (attack==wSword ? wSword : wWand))
26738 {
26739 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26740 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
26741 positionSword(swd,item_id);
26742 break;
26743 }
26744 }
26745 }
26746 6973 FFCore.clear_combo_scripts();
26747
4/4
✓ Branch 0 taken 2422 times.
✓ Branch 1 taken 4551 times.
✓ Branch 2 taken 2170 times.
✓ Branch 3 taken 252 times.
6973 if (!intradmap || get_qr(qr_WARPS_RESTART_DMAPSCRIPT))
26748 {
26749 6721 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
26750 6721 FFCore.initZScriptDMapScripts();
26751 6721 FFCore.initZScriptScriptedActiveSubscreen();
26752 6721 }
26753 6973 is_warping = false;
26754
2/2
✓ Branch 0 taken 6709 times.
✓ Branch 1 taken 264 times.
6973 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
26755 264 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
26756 6973 return true;
26757 7124 }
26758
26759 373 void HeroClass::exitcave()
26760 {
26761 373 bool updatemusic = FFCore.can_dmap_change_music(cur_dmap);
26762 373 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
26763
26764 373 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
26765 373 loadscr(cur_dmap, home_screen, 255, false); // bogus direction
26766 373 x = hero_scr->warpreturnx[0];
26767 373 y = hero_scr->warpreturny[0];
26768
26769
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(didpit)
26770 {
26771 didpit=false;
26772 x=pitx;
26773 y=pity;
26774 }
26775
26776
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 18 times.
373 if(x+y == 0)
26777 18 x = y = 80;
26778
26779 373 x += region_scr_dx*256;
26780 373 y += region_scr_dy*176;
26781 373 update_viewport();
26782
26783 373 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26784 373 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26785 373 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26786
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 331 times.
724 bool b = COOLSCROLL &&
26787
4/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 211 times.
331 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
26788
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 208 times.
211 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
26789
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 190 times.
208 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
26790
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 5 times.
190 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
26791 393 ALLOFF();
26792 393 blackscr(30,b?false:true);
26793 393 ringcolor(false);
26794 393 loadlvlpal(DMaps[cur_dmap].color);
26795 393 lighting(false, true);
26796
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 10 times.
393 if (updatemusic || !musicnocut)
26797 403 music_stop();
26798 413 kill_sfx();
26799 413 putscr(hero_scr, scrollbuf, 0, 0);
26800 413 putscrdoors(hero_scr, scrollbuf, 0, 0);
26801
26802
10/10
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 235 times.
✓ Branch 4 taken 237 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 232 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
413 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26803 {
26804 166 walkup(COOLSCROLL);
26805 166 }
26806
9/10
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 219 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 214 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
239 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26807 {
26808 22 walkdown2(COOLSCROLL);
26809 22 }
26810
26811 403 show_subscreen_life=true;
26812 403 show_subscreen_numbers=true;
26813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
403 if (updatemusic || !musicnocut)
26814 403 playLevelMusic();
26815 403 currcset=DMaps[cur_dmap].color;
26816 403 dointro();
26817 403 newscr_clk=frame;
26818 403 activated_timed_warp=false;
26819 403 dir=down;
26820 403 set_respawn_point();
26821 403 eat_buttons();
26822 403 didstuff=0;
26823 403 usecounts.clear();
26824 403 map_bkgsfx(true);
26825 403 loadside=dir^1;
26826 403 }
26827
26828
26829 11096 void HeroClass::stepforward(int32_t steps, bool adjust)
26830 {
26831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11096 times.
11096 if ( FFCore.nostepforward ) return;
26832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11096 times.
11096 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
26833 11096 zfix tx=x; //temp x
26834 11096 zfix ty=y; //temp y
26835 11096 zfix tstep(0); //temp single step distance
26836 11096 zfix s(0); //calculated step distance for all steps
26837 11096 z3step=2;
26838 11096 int32_t sh=shiftdir;
26839 11096 shiftdir=-1;
26840
26841
2/2
✓ Branch 0 taken 189538 times.
✓ Branch 1 taken 11096 times.
200634 for(int32_t i=steps; i>0; --i)
26842 {
26843
2/2
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 189039 times.
189538 if(diagonalMovement)
26844 {
26845
3/4
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
499 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26846 {
26847 236 tstep = 1.5;
26848 236 }
26849 else
26850 {
26851 263 tstep=z3step;
26852 263 z3step=(z3step%2)+1;
26853 }
26854 499 }
26855 else
26856 {
26857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189039 times.
189039 if(get_qr(qr_NEW_HERO_MOVEMENT))
26858 {
26859 tstep = 1.5;
26860 }
26861 else
26862 {
26863
2/2
✓ Branch 0 taken 105445 times.
✓ Branch 1 taken 83594 times.
189039 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
26864
26865
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 60103 times.
✓ Branch 2 taken 45342 times.
✓ Branch 3 taken 38591 times.
✓ Branch 4 taken 45003 times.
189039 switch(dir)
26866 {
26867 case up:
26868 60103 ty-=tstep;
26869 60103 break;
26870
26871 case down:
26872 45342 ty+=tstep;
26873 45342 break;
26874
26875 case left:
26876 38591 tx-=tstep;
26877 38591 break;
26878
26879 case right:
26880 45003 tx+=tstep;
26881 45003 break;
26882 }
26883 }
26884 }
26885
26886 189538 s+=tstep;
26887 189538 }
26888
26889 11096 z3step=2;
26890
26891 11096 x = x.getInt();
26892 11096 y = y.getInt();
26893
2/2
✓ Branch 0 taken 200401 times.
✓ Branch 1 taken 11093 times.
211494 while(s>=0)
26894 {
26895
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 199900 times.
200401 if(diagonalMovement)
26896 {
26897
5/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
501 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26898 {
26899 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26900 {
26901 walkable = false;
26902 shiftdir = -1;
26903 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26904 switch(tdir)
26905 {
26906 case left:
26907 --x;
26908 break;
26909 case right:
26910 ++x;
26911 break;
26912 case up:
26913 --y;
26914 break;
26915 case down:
26916 ++y;
26917 break;
26918 }
26919 }
26920 else
26921 {
26922 walkable=false;
26923 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26924 moveOld2(dir, 150);
26925 }
26926 }
26927 else
26928 {
26929
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
501 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26930 {
26931 257 s-=1.5;
26932 257 }
26933 else
26934 {
26935 244 s-=z3step;
26936 }
26937 501 walkable=true;
26938 501 moveOld2(dir, 150);
26939 }
26940
26941 501 shiftdir=-1;
26942 501 }
26943 else
26944 {
26945
3/6
✓ Branch 0 taken 111689 times.
✓ Branch 1 taken 88211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 199900 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
199900 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
26946 {
26947 walkable=false;
26948 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
26949 switch(tdir)
26950 {
26951 case left:
26952 --x;
26953 break;
26954 case right:
26955 ++x;
26956 break;
26957 case up:
26958 --y;
26959 break;
26960 case down:
26961 ++y;
26962 break;
26963 }
26964 }
26965 else
26966 {
26967
2/4
✓ Branch 0 taken 199900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 199900 times.
199900 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
26968 {
26969 s-=1.5;
26970 }
26971
2/2
✓ Branch 0 taken 111689 times.
✓ Branch 1 taken 88211 times.
199900 else if(dir<left)
26972 {
26973 111689 s-=lsteps[y.getInt()&7];
26974 111689 }
26975 else
26976 {
26977 88211 s-=lsteps[x.getInt()&7];
26978 }
26979
26980 199900 moveOld2(dir, 150);
26981 }
26982 }
26983
26984
2/2
✓ Branch 0 taken 189308 times.
✓ Branch 1 taken 11093 times.
200401 if(s<0)
26985 {
26986 // Not quite sure how this is actually supposed to work.
26987 // There have to be two cases for each direction or Hero
26988 // either walks too far onto the screen or may get stuck
26989 // going through walk-through walls.
26990
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4002 times.
✓ Branch 2 taken 2455 times.
✓ Branch 3 taken 2115 times.
✓ Branch 4 taken 2521 times.
11093 switch(dir)
26991 {
26992 case up:
26993
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 3777 times.
4002 if(y<8) // Leaving the screen
26994 225 y+=s;
26995 else // Entering the screen
26996 3777 y-=s;
26997
26998 4002 break;
26999
27000 case down:
27001
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 2239 times.
2455 if(y>152)
27002 216 y-=s;
27003 else
27004 2239 y+=s;
27005
27006 2455 break;
27007
27008 case left:
27009
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 1940 times.
2115 if(x<8)
27010 175 x+=s;
27011 else
27012 1940 x-=s;
27013
27014 2115 break;
27015
27016 case right:
27017
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 2326 times.
2521 if(x>=232)
27018 195 x-=s;
27019 else
27020 2326 x+=s;
27021
27022 2521 break;
27023 }
27024 11093 }
27025
27026 200401 clear_darkroom_bitmaps();
27027 200401 update_viewport();
27028 200401 draw_screen();
27029
1/2
✓ Branch 0 taken 200401 times.
✗ Branch 1 not taken.
200401 if (canSideviewLadder()) setOnSideviewLadder(true);
27030 200401 advanceframe(true);
27031
27032
2/2
✓ Branch 0 taken 200398 times.
✓ Branch 1 taken 3 times.
200401 if(Quit)
27033 3 return;
27034 }
27035
4/4
✓ Branch 0 taken 8572 times.
✓ Branch 1 taken 2521 times.
✓ Branch 2 taken 2455 times.
✓ Branch 3 taken 6117 times.
11093 if(dir==right||dir==down)
27036 {
27037 4976 x=int32_t(x);
27038 4976 y=int32_t(y);
27039 4976 }
27040 else
27041 {
27042 6117 x = x.getInt();
27043 6117 y = y.getInt();
27044 }
27045 11093 set_respawn_point();
27046 11093 draw_screen();
27047 11093 eat_buttons();
27048 11093 shiftdir=sh;
27049 11096 }
27050
27051 1272 void HeroClass::setpit()
27052 {
27053 1272 didpit = true;
27054 1272 pitx = x.getInt() % 256;
27055 1272 pity = y.getInt() % 176;
27056 1272 }
27057
27058 458 void HeroClass::walkdown(bool opening) //entering cave
27059 {
27060
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 398 times.
458 if(opening)
27061 {
27062 398 close_black_opening(x+8, y+8+playing_field_offset, false);
27063 398 }
27064
27065 458 hclk=0;
27066 458 stop_item_sfx(itype_brang);
27067 458 sfx(WAV_STAIRS,pan(x.getInt()));
27068 458 clk=0;
27069 // Fix Hero's position to the grid
27070 458 y=TRUNCATE_TILE(y.getInt());
27071 458 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27072 458 attack=wNone;
27073 458 attackid=-1;
27074 458 reset_swordcharge();
27075 458 climb_cover_x=TRUNCATE_TILE(x.getInt());
27076 458 climb_cover_y=TRUNCATE_TILE(y.getInt()) + 16;
27077
27078 458 guys.clear();
27079 458 chainlinks.clear();
27080 458 Lwpns.clear();
27081 458 Ewpns.clear();
27082 458 items.clear();
27083
27084
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 29312 times.
29770 for(int32_t i=0; i<64; i++)
27085 {
27086 29312 herostep();
27087
27088
2/4
✓ Branch 0 taken 29312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29312 times.
29312 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27089 hero_count=(hero_count+1)%16;
27090
27091
2/2
✓ Branch 0 taken 21984 times.
✓ Branch 1 taken 7328 times.
29312 if((i&3)==3)
27092 {
27093 7328 ++y;
27094 7328 update_viewport();
27095 7328 }
27096
27097 29312 draw_screen();
27098 29312 advanceframe(true);
27099
27100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29312 times.
29312 if(Quit)
27101 break;
27102 29312 }
27103
27104 458 action=none; FFCore.setHeroAction(none);
27105 458 }
27106
27107 120 void HeroClass::walkdown2(bool opening) //exiting cave 2
27108 {
27109 120 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27110
27111
27112 // Fix Hero's position to the grid
27113 120 y=TRUNCATE_TILE(y.getInt());
27114
27115
3/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27116 99 y -= 16;
27117
27118 120 climb_cover_x=TRUNCATE_TILE(x.getInt());
27119 120 climb_cover_y=TRUNCATE_TILE(y.getInt());
27120
27121 120 dir=down;
27122 120 z=fakez=fall=fakefall=0;
27123
27124
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 25 times.
120 if(opening)
27125 {
27126 25 open_black_opening(x+8, y+8+playing_field_offset+16, false);
27127 25 }
27128
27129 120 hclk=0;
27130 120 stop_item_sfx(itype_brang);
27131 120 sfx(WAV_STAIRS,pan(x.getInt()));
27132 120 clk=0;
27133 120 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27134 120 attack=wNone;
27135 120 attackid=-1;
27136 120 reset_swordcharge();
27137
27138 120 guys.clear();
27139 120 chainlinks.clear();
27140 120 Lwpns.clear();
27141 120 Ewpns.clear();
27142 120 items.clear();
27143
27144
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 7680 times.
7800 for(int32_t i=0; i<64; i++)
27145 {
27146 7680 herostep();
27147
27148
2/4
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7680 times.
7680 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27149 hero_count=(hero_count+1)%16;
27150
27151
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 if((i&3)==3)
27152 {
27153 1920 ++y;
27154 1920 update_viewport();
27155 1920 }
27156
27157 7680 draw_screen();
27158 7680 advanceframe(true);
27159
27160
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(Quit)
27161 break;
27162 7680 }
27163
27164
27165 120 action=none; FFCore.setHeroAction(none);
27166 120 }
27167
27168 380 void HeroClass::walkup(bool opening) //exiting cave
27169 {
27170 380 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27171
27172
5/6
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
380 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27173 55 y+=16;
27174
27175 // Fix Hero's position to the grid
27176 380 y=TRUNCATE_TILE(y.getInt());
27177 380 z=fakez=fall=fakefall=0;
27178
27179
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 331 times.
380 if(opening)
27180 {
27181 331 open_black_opening(x+8, y+8+playing_field_offset-16, false);
27182 331 }
27183
27184 380 hclk=0;
27185 380 stop_item_sfx(itype_brang);
27186 380 sfx(WAV_STAIRS,pan(x.getInt()));
27187 380 dir=down;
27188 380 clk=0;
27189 380 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27190 380 attack=wNone;
27191 380 attackid=-1;
27192 380 reset_swordcharge();
27193 380 climb_cover_x=TRUNCATE_TILE(x.getInt());
27194 380 climb_cover_y=TRUNCATE_TILE(y.getInt());
27195
27196 380 guys.clear();
27197 380 chainlinks.clear();
27198 380 Lwpns.clear();
27199 380 Ewpns.clear();
27200 380 items.clear();
27201
27202
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 24320 times.
24700 for(int32_t i=0; i<64; i++)
27203 {
27204 24320 herostep();
27205
27206
2/4
✓ Branch 0 taken 24320 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24320 times.
24320 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27207 hero_count=(hero_count+1)%16;
27208
27209
2/2
✓ Branch 0 taken 18240 times.
✓ Branch 1 taken 6080 times.
24320 if((i&3)==0)
27210 {
27211 6080 --y;
27212 6080 update_viewport();
27213 6080 }
27214
27215 24320 draw_screen();
27216 24320 advanceframe(true);
27217
27218
1/2
✓ Branch 0 taken 24320 times.
✗ Branch 1 not taken.
24320 if(Quit)
27219 break;
27220 24320 }
27221
27222 380 map_bkgsfx(true);
27223 380 loadside=dir^1;
27224 380 action=none; FFCore.setHeroAction(none);
27225 380 }
27226
27227 423 void HeroClass::walkup2(bool opening) //entering cave2
27228 {
27229
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 327 times.
423 if(opening)
27230 {
27231 327 close_black_opening(x+8, y+8+playing_field_offset, false);
27232 327 }
27233
27234 423 hclk=0;
27235 423 stop_item_sfx(itype_brang);
27236 423 sfx(WAV_STAIRS,pan(x.getInt()));
27237 423 dir=up;
27238 423 clk=0;
27239 423 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27240 423 attack=wNone;
27241 423 attackid=-1;
27242 423 reset_swordcharge();
27243 423 TRUNCATE_TILE(x.getInt());
27244 423 climb_cover_x=TRUNCATE_TILE(x.getInt());
27245 423 climb_cover_y=TRUNCATE_TILE(y.getInt()) - 16;
27246
27247 423 guys.clear();
27248 423 chainlinks.clear();
27249 423 Lwpns.clear();
27250 423 Ewpns.clear();
27251 423 items.clear();
27252
27253
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 27072 times.
27495 for(int32_t i=0; i<64; i++)
27254 {
27255 27072 herostep();
27256
27257
2/4
✓ Branch 0 taken 27072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27072 times.
27072 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27258 hero_count=(hero_count+1)%16;
27259
27260
2/2
✓ Branch 0 taken 20304 times.
✓ Branch 1 taken 6768 times.
27072 if((i&3)==0)
27261 {
27262 6768 --y;
27263 6768 update_viewport();
27264 6768 }
27265
27266 27072 draw_screen();
27267 27072 advanceframe(true);
27268
27269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27072 times.
27072 if(Quit)
27270 break;
27271 27072 }
27272 423 map_bkgsfx(true);
27273 423 loadside=dir^1;
27274 423 action=none; FFCore.setHeroAction(none);
27275 423 }
27276
27277 455 void HeroClass::stepout() // Step out of item cellars and passageways
27278 {
27279 455 bool updatemusic = FFCore.can_dmap_change_music(cur_dmap);
27280 455 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
27281
27282 455 int32_t sc = specialcave; // This gets erased by ALLOFF()
27283 455 ALLOFF();
27284 455 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27285 455 kill_sfx();
27286 455 draw_screen(false);
27287 455 fade(sc>=GUYCAVE?10:11,true,false);
27288 455 blackscr(30,true);
27289 455 ringcolor(false);
27290
27291
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 271 times.
455 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
27292 {
27293 271 cur_dmap=stepoutdmap;
27294 271 cur_map=DMaps[cur_dmap].map;
27295 271 dlevel=DMaps[cur_dmap].level;
27296
27297 //we might have just left a passage, so be sure to update the CSet record -DD
27298 271 currcset=DMaps[cur_dmap].color;
27299
27300 271 init_dmap();
27301 271 home_screen=stepoutscreen;
27302 271 }
27303
27304 455 loadscr(cur_dmap, home_screen, 255, false); // bogus direction
27305 455 draw_screen(false);
27306
27307
4/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 10 times.
455 if(get_qr(qr_NEW_DARKROOM) || !is_dark(hero_scr))
27308 {
27309 445 darkroom = naturaldark = false;
27310 445 fade(DMaps[cur_dmap].color,true,true);
27311 445 }
27312 else
27313 {
27314 10 darkroom = naturaldark = true;
27315
27316
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(get_qr(qr_FADE))
27317 {
27318 8 interpolatedfade();
27319 8 }
27320 else
27321 {
27322 2 loadfadepal((DMaps[cur_dmap].color)*pdLEVEL+poFADE3);
27323 }
27324 10 byte *si = colordata + CSET(DMaps[cur_dmap].color*pdLEVEL+poLEVEL)*3;
27325 10 si+=3*48;
27326
27327
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 10 times.
170 for(int32_t i=0; i<16; i++)
27328 {
27329 160 RAMpal[CSET(9)+i] = _RGB(si);
27330 160 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
27331 160 si+=3;
27332 160 }
27333 }
27334
27335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 455 times.
455 if(didpit)
27336 {
27337 didpit=false;
27338 x=pitx;
27339 y=pity;
27340 }
27341 else
27342 {
27343 455 x = hero_scr->warpreturnx[stepoutwr];
27344 455 y = hero_scr->warpreturny[stepoutwr];
27345 }
27346
27347 455 x += region_scr_dx * 256;
27348 455 y += region_scr_dy * 176;
27349 455 update_viewport();
27350
27351
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 20 times.
455 if(x+y == 0)
27352 20 x = y = 80;
27353
27354 455 dir=down;
27355
27356 455 set_respawn_point();
27357
27358 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
27359 455 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27360
27361
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27362 {
27363 walkup(false);
27364 }
27365
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27366 {
27367 walkdown2(false);
27368 }
27369
27370 455 newscr_clk=frame;
27371 455 activated_timed_warp=false;
27372 455 didstuff=0;
27373 455 usecounts.clear();
27374 455 eat_buttons();
27375 455 markBmap();
27376 455 map_bkgsfx(true);
27377
27378
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 54 times.
455 if(!get_qr(qr_CAVEEXITNOSTOPMUSIC))
27379 {
27380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (updatemusic || !musicnocut)
27381 {
27382 54 music_stop();
27383 54 playLevelMusic();
27384 54 }
27385 54 }
27386
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 else if(get_qr(qr_SCREEN80_OWN_MUSIC))
27387 {
27388 if (updatemusic || !musicnocut)
27389 playLevelMusic();
27390 }
27391
27392 455 loadside=dir^1;
27393 455 }
27394
27395 31559 bool HeroClass::nextcombo_wf(int32_t d2)
27396 {
27397
6/8
✓ Branch 0 taken 31497 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 31058 times.
✓ Branch 3 taken 439 times.
✓ Branch 4 taken 31058 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 439 times.
✗ Branch 7 not taken.
31559 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
27398 31559 return false;
27399
27400 // assumes Hero is about to scroll screens
27401 auto [map, screen] = nextscr2(d2);
27402 if (map == -1)
27403 return false;
27404
27405 const mapscr* scr = get_canonical_scr(map, screen);
27406
27407 int32_t cx = x;
27408 int32_t cy = y;
27409
27410 switch(d2)
27411 {
27412 case up:
27413 cy=160;
27414 break;
27415
27416 case down:
27417 cy=0;
27418 break;
27419
27420 case left:
27421 cx=240;
27422 break;
27423
27424 case right:
27425 cx=0;
27426 break;
27427 }
27428
27429 // check lower half of combo
27430 cy += 8;
27431
27432 int32_t cmb = COMBOPOS(cx%256, cy%176);
27433 const newcombo* c = &combobuf[scr->data[cmb]];
27434 bool dried = iswater_type(c->type) && DRIEDLAKE;
27435 bool swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27436 int32_t b=1;
27437
27438 if(cx&8) b<<=2;
27439
27440 if(cy&8) b<<=1;
27441
27442 if((c->walk&b) && !dried && !swim)
27443 return true;
27444
27445 // next block (i.e. cnt==2)
27446 if(!(cx&8))
27447 {
27448 b<<=2;
27449 }
27450 else
27451 {
27452 c = &combobuf[scr->data[++cmb]];
27453 dried = iswater_type(c->type) && DRIEDLAKE;
27454 swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27455 b=1;
27456
27457 if(cy&8)
27458 {
27459 b<<=1;
27460 }
27461 }
27462
27463 return (c->walk&b) ? !dried && !swim : false;
27464 31559 }
27465
27466 446 bool HeroClass::nextcombo_solid(int32_t d2)
27467 {
27468
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(toogam || cur_screen>=128)
27469 return false;
27470
27471 // assumes Hero is about to scroll screens
27472 12406 auto [map, screen] = nextscr2(d2);
27473
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if (map == -1)
27474 return false;
27475
27476 446 int32_t cx = x;
27477 446 int32_t cy = y;
27478 446 cx %= 256;
27479 446 cy %= 176;
27480
27481
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 252 times.
446 switch(d2)
27482 {
27483 case up:
27484 20 cy=160;
27485 20 break;
27486
27487 case down:
27488 70 cy=0;
27489 70 break;
27490
27491 case left:
27492 104 cx=240;
27493 104 break;
27494
27495 case right:
27496 252 cx=0;
27497 252 break;
27498 }
27499
27500
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 426 times.
446 if(d2==up) cy += 8;
27501
27502
4/4
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 90 times.
446 if(d2==left||d2==right) cy+=bigHitbox?0:8;
27503
27504 446 int32_t initcx = cx;
27505 446 int32_t initcy = cy;
27506 446 bool smarter_scroll = get_qr(qr_SMARTER_SMART_SCROLL);
27507 // from MAPCOMBO()
27508
27509
10/10
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 382 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 350 times.
✓ Branch 6 taken 232 times.
✓ Branch 7 taken 702 times.
✓ Branch 8 taken 674 times.
✓ Branch 9 taken 260 times.
934 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
27510 {
27511 674 cx = initcx;
27512
5/6
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1196 times.
✓ Branch 4 taken 1196 times.
✓ Branch 5 taken 488 times.
1684 for(int32_t k=0; k<=(smarter_scroll?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
27513 {
27514 2392 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, smarter_scroll)];
27515
27516 1196 int32_t b=1;
27517
27518
2/2
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 552 times.
1196 if(cx&8) b<<=2;
27519
27520
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 580 times.
1196 if(cy&8) b<<=1;
27521
27522 //bool bridgedetected = false;
27523
27524 1196 int32_t walk = c.walk;
27525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if (smarter_scroll)
27526 {
27527
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 1196 times.
3588 for (int32_t m = 0; m <= 1; m++)
27528 {
27529 4784 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
27530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2392 times.
2392 if (cmb.type == cBRIDGE)
27531 {
27532 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
27533 {
27534 int efflag = (cmb.walk & 0xF0)>>4;
27535 int newsolid = (cmb.walk & 0xF);
27536 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
27537 }
27538 else walk &= cmb.walk;
27539 }
27540 2392 else walk |= cmb.walk;
27541 2392 }
27542 1196 }
27543
27544
4/10
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1196 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1196 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4784 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, smarter_scroll), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
27545
27546
3/4
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 1010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 186 times.
1196 if((walk&b) && !swim)
27547 {
27548 186 return true;
27549 }
27550 1010 }
27551 488 }
27552
27553 260 return false;
27554 446 }
27555
27556 30436 void HeroClass::do_scroll_direction(direction dir)
27557 {
27558 30436 bool should_scroll = true;
27559
27560
5/6
✓ Branch 0 taken 30281 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 30281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30291 times.
✓ Branch 5 taken 145 times.
30436 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27561 145 should_scroll = false;
27562
27563
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30355 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
30436 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27564 should_scroll = false;
27565
27566
1/2
✓ Branch 0 taken 30436 times.
✗ Branch 1 not taken.
30436 if(nextcombo_wf(dir))
27567 should_scroll = false;
27568
27569 30436 int dir_flag = 0;
27570
2/2
✓ Branch 0 taken 21640 times.
✓ Branch 1 taken 8796 times.
30436 if (dir == up) dir_flag = wfUP;
27571
2/2
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 14497 times.
21640 else if (dir == down) dir_flag = wfDOWN;
27572
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 7777 times.
14497 else if (dir == left) dir_flag = wfLEFT;
27573
1/2
✓ Branch 0 taken 7777 times.
✗ Branch 1 not taken.
7777 else if (dir == right) dir_flag = wfRIGHT;
27574 else assert(false);
27575
27576 30436 mapscr* scr = hero_scr;
27577
27578
9/10
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 29946 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 474 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 474 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 446 times.
✓ Branch 9 taken 28 times.
30436 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(scr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(scr->flags2&dir_flag))
27579 {
27580
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 186 times.
446 if(nextcombo_solid(dir))
27581 186 should_scroll = false;
27582 446 }
27583
27584
4/4
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 30151 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 284 times.
30436 if (should_scroll || action == inwind)
27585 {
27586
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 29349 times.
30152 if(cur_screen>=128)
27587 {
27588
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 455 times.
801 if(specialcave >= GUYCAVE)
27589 346 exitcave();
27590 455 else stepout();
27591 801 }
27592
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 29223 times.
29349 else if(action==inwind)
27593 {
27594
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 125 times.
126 if(DMaps[cur_dmap].flags&dmfWHIRLWINDRET)
27595 {
27596 1 action=none; FFCore.setHeroAction(none);
27597 1 restart_level();
27598 1 }
27599 else
27600 {
27601 125 dowarp(scr, 2, dir);
27602 }
27603 126 }
27604
3/6
✓ Branch 0 taken 1943 times.
✓ Branch 1 taken 27280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29223 else if(scr->flags2&dir_flag && (!(scr->flags8&fMAZEvSIDEWARP) || checkmaze(scr,false)))
27605 {
27606 1943 sdir=dir;
27607 1943 dowarp(scr, 1, (scr->sidewarpindex >> (sdir*2))&3);
27608 1943 }
27609
4/4
✓ Branch 0 taken 26924 times.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 26923 times.
27280 else if(!edge_of_dmap(dir) && edge_of_region(dir))
27610 {
27611 26923 scrolling_dmap = cur_dmap;
27612 26923 scrolling_map = cur_map;
27613 26923 scrollscr(dir);
27614
27615
1/2
✓ Branch 0 taken 26923 times.
✗ Branch 1 not taken.
26923 if(hero_scr->flags4&fAUTOSAVE)
27616 {
27617 save_game(true,0);
27618 }
27619
27620
2/2
✓ Branch 0 taken 26394 times.
✓ Branch 1 taken 529 times.
26923 if(hero_scr->flags6&fCONTINUEHERE)
27621 {
27622 529 lastentrance_dmap = cur_dmap;
27623 529 lastentrance = home_screen;
27624 529 }
27625 26923 }
27626 30150 }
27627 30434 }
27628
27629 142086 static bool has_advanced_maze(mapscr* scr)
27630 {
27631 142086 bool loopy = scr->flags10&fMAZE_LOOPY;
27632 142086 bool can_get_lost = scr->flags10&fMAZE_CAN_GET_LOST;
27633 142086 int maze_transition_wipe = scr->maze_transition_wipe;
27634
5/6
✓ Branch 0 taken 142080 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 142062 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 142062 times.
✗ Branch 5 not taken.
142086 return loopy || can_get_lost || maze_transition_wipe || is_in_scrolling_region();
27635 }
27636
27637 14322913 void HeroClass::maybe_begin_advanced_maze()
27638 {
27639
6/6
✓ Branch 0 taken 60486 times.
✓ Branch 1 taken 14262427 times.
✓ Branch 2 taken 60108 times.
✓ Branch 3 taken 378 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 60086 times.
14322913 if (!(hero_scr->flags&fMAZE) || hero_screen == scrolling_maze_last_solved_screen || maze_state.active)
27640 14262827 return;
27641
27642 // Basic mazes are handled in scrollscr.
27643
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 60070 times.
60086 if (!has_advanced_maze(hero_scr))
27644 60070 return;
27645
27646 16 maze_state = {};
27647 maze_state.active = true;
27648 maze_state.loopy = hero_scr->flags10&fMAZE_LOOPY;
27649 maze_state.transition_wipe = hero_scr->maze_transition_wipe;
27650 maze_state.can_get_lost = hero_scr->flags10&fMAZE_CAN_GET_LOST;
27651 maze_state.scr = hero_scr;
27652 maze_state.exit_screen = screen_index_direction(hero_screen, (direction)hero_scr->exitdir);
27653 maze_state.last_check_herox = x;
27654 maze_state.last_check_heroy = y;
27655
27656
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if (maze_state.loopy)
27657 {
27658 6 int dx = get_region_relative_dx(prev_hero_scr->screen) - get_region_relative_dx(hero_screen);
27659 6 int dy = get_region_relative_dy(prev_hero_scr->screen) - get_region_relative_dy(hero_screen);
27660 6 maze_state.enter_dir = XY_DELTA_TO_DIR(sign2(dx), sign2(dy));
27661 6 }
27662 }
27663
27664 // Checks if hero is beyond the bounds of the screen, and if so begins scrolling.
27665 // Returns after scrolling is finished.
27666 14307783 void HeroClass::checkscroll()
27667 {
27668 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
27669
3/4
✓ Branch 0 taken 14303885 times.
✓ Branch 1 taken 3898 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14303885 times.
14307783 if(action == casting||action==sideswimcasting)
27670 3898 return;
27671
27672
1/2
✓ Branch 0 taken 14303885 times.
✗ Branch 1 not taken.
14303885 if(!check_prescroll()) // prevent scrolling when you should drown/fall/etc before the screen edge
27673 return;
27674
27675
4/4
✓ Branch 0 taken 18355 times.
✓ Branch 1 taken 14285530 times.
✓ Branch 2 taken 9285 times.
✓ Branch 3 taken 9070 times.
14303885 if (action == inwind && whirlwind == 0)
27676 {
27677
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 8956 times.
9070 if (x > viewport.right()-16)
27678 {
27679 114 x = viewport.right()-16;
27680 114 do_scroll_direction(right);
27681 114 }
27682
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8954 times.
8956 else if (x < viewport.left())
27683 {
27684 2 x = viewport.left();
27685 2 do_scroll_direction(left);
27686 2 }
27687
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8950 times.
8954 else if (y > viewport.bottom()-16)
27688 {
27689 4 y = viewport.bottom()-16;
27690 4 do_scroll_direction(down);
27691 4 }
27692
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8944 times.
8950 else if (y < viewport.top())
27693 {
27694 6 y = viewport.top();
27695 6 do_scroll_direction(up);
27696 6 }
27697
27698 9070 return;
27699 }
27700
27701
2/2
✓ Branch 0 taken 7762 times.
✓ Branch 1 taken 14287053 times.
14294815 if (!maze_state.active)
27702 14287053 maybe_begin_advanced_maze();
27703
27704
2/2
✓ Branch 0 taken 14287045 times.
✓ Branch 1 taken 7770 times.
14294815 if (maze_state.active)
27705 {
27706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7770 times.
7770 if (action == inwind)
27707 {
27708 maze_state.active = false;
27709 return;
27710 }
27711
27712
2/2
✓ Branch 0 taken 3602 times.
✓ Branch 1 taken 4168 times.
7770 if (!maze_state.lost)
27713 {
27714
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4162 times.
4168 if (determine_hero_screen_from_coords()->screen == maze_state.exit_screen)
27715 {
27716 6 maze_state.active = false;
27717 6 update_heroscr();
27718 6 return;
27719 }
27720
27721
3/4
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 3608 times.
✓ Branch 2 taken 554 times.
✗ Branch 3 not taken.
4162 if (maze_state.enter_dir != dir_invalid && determine_hero_screen_from_coords() == prev_hero_scr)
27722 {
27723 maze_state.active = false;
27724 update_heroscr();
27725 return;
27726 }
27727 4162 }
27728
27729 7764 int maze_screen = maze_state.scr->screen;
27730 38820 auto [sx, sy] = translate_screen_coordinates_to_world(maze_screen);
27731
27732 7764 int x0 = x.getInt();
27733 7764 int y0 = y.getInt();
27734 7764 direction advance_dir = dir_invalid;
27735
5/6
✓ Branch 0 taken 7642 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 7642 times.
✓ Branch 3 taken 122 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7642 times.
15528 if (x0 > (sx+256)-16 || x0 > world_w - 16) advance_dir = right;
27736
5/6
✓ Branch 0 taken 7732 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 7732 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 7732 times.
✗ Branch 5 not taken.
15528 if (x0 < sx || x0 < 0) advance_dir = left;
27737
5/6
✓ Branch 0 taken 7718 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 7718 times.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7718 times.
15528 if (y0 > (sy+176)-16 || y0 > world_h - 16) advance_dir = down;
27738
5/6
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 7720 times.
✗ Branch 5 not taken.
15528 if (y0 < sy || y0 < 0) advance_dir = up;
27739
27740
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 7520 times.
7764 if (advance_dir == dir_invalid)
27741 {
27742 7520 maze_state.last_check_herox = -10000;
27743 7520 maze_state.last_check_heroy = -10000;
27744 7520 }
27745 else
27746 {
27747
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 198 times.
244 bool can_check_again = std::abs(maze_state.last_check_herox - x0) >= 16 || std::abs(maze_state.last_check_heroy - y0) >= 16;
27748
27749
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
244 if (can_check_again && maze_enabled_sizewarp(maze_state.scr, advance_dir))
27750 {
27751 maze_state.active = false;
27752 return;
27753 }
27754
27755
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 134 times.
✓ Branch 3 taken 12 times.
390 bool found_exit = !maze_state.lost && (lastdir[3] == maze_state.scr->exitdir || lastdir[3] == maze_state.enter_dir);
27756
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 110 times.
244 if (found_exit)
27757 {
27758 // Do nothing.
27759 134 }
27760
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6 times.
110 else if (can_check_again && checkmaze_ignore_exit(maze_state.scr, true))
27761 {
27762 6 maze_state.last_check_herox = x;
27763 6 maze_state.last_check_heroy = y;
27764 6 maze_state.enter_dir = dir_invalid;
27765
27766 6 int dest_screen = screen_index_direction(maze_screen, advance_dir);
27767
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (is_in_current_region(dest_screen))
27768 4 scrolling_maze_last_solved_screen = maze_screen;
27769 else
27770 2 scrollscr(advance_dir, dest_screen);
27771
27772 6 maze_state.active = false;
27773 6 }
27774
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 10 times.
104 else if (can_check_again && maze_state.loopy)
27775 {
27776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.transition_wipe)
27777 10 closescreen(maze_state.transition_wipe - 1);
27778
27779
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == left) x += 256;
27780
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == right) x -= 256;
27781
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == up) y += 176;
27782
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (advance_dir == down) y -= 176;
27783
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
10 if (advance_dir == left || advance_dir == right)
27784 4 x.doClamp(0, world_w - 16);
27785
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
10 if (advance_dir == up || advance_dir == down)
27786 6 y.doClamp(0, world_h - 16);
27787
27788 10 maze_state.last_check_herox = x;
27789 10 maze_state.last_check_heroy = y;
27790 10 maze_state.enter_dir = dir_invalid;
27791
27792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.can_get_lost)
27793 {
27794
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (advance_dir == maze_state.scr->exitdir)
27795 2 maze_state.lost = false;
27796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if (advance_dir != maze_state.enter_dir)
27797 8 maze_state.lost = true;
27798 10 }
27799
27800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.transition_wipe)
27801 10 openscreen(maze_state.transition_wipe - 1);
27802 10 }
27803
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 22 times.
94 else if (!maze_state.loopy)
27804 {
27805
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (maze_state.transition_wipe)
27806 closescreen(maze_state.transition_wipe - 1);
27807
27808 22 loadscr(cur_dmap, hero_screen, -1, false);
27809 22 maze_state.scr = get_scr(maze_screen);
27810
27811 // A bit janky, but works: clear all state (as usual during a screen change), but keep
27812 // the maze state.
27813 22 auto prev_maze_state = maze_state;
27814 22 ALLOFF();
27815 22 maze_state = prev_maze_state;
27816
27817
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == left) x = (get_region_relative_dx(maze_screen) + 1) * 256 - 16;
27818
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4 times.
22 if (advance_dir == right) x = (get_region_relative_dx(maze_screen)) * 256;
27819
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == up) y = (get_region_relative_dy(maze_screen) + 1) * 176 - 16;
27820
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == down) y = (get_region_relative_dy(maze_screen)) * 176;
27821
27822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (maze_state.can_get_lost)
27823 {
27824
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18 times.
22 if (advance_dir == maze_state.scr->exitdir)
27825 4 maze_state.lost = false;
27826 else
27827 18 maze_state.lost = true;
27828 22 }
27829
27830
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (maze_state.transition_wipe)
27831 openscreen(maze_state.transition_wipe - 1);
27832 22 }
27833 }
27834
27835
6/6
✓ Branch 0 taken 7758 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4156 times.
✓ Branch 3 taken 3602 times.
✓ Branch 4 taken 4052 times.
✓ Branch 5 taken 104 times.
7764 if (maze_state.active && (maze_state.lost || advance_dir != maze_state.scr->exitdir))
27836 7654 return;
27837 110 }
27838
27839
2/2
✓ Branch 0 taken 14279492 times.
✓ Branch 1 taken 7663 times.
14287155 if (x > world_w-16)
27840 {
27841 7663 x = world_w-16;
27842 7663 do_scroll_direction(right);
27843 7663 }
27844
2/2
✓ Branch 0 taken 14280437 times.
✓ Branch 1 taken 6718 times.
14287155 if (x < 0)
27845 {
27846 6718 x = 0;
27847 6718 do_scroll_direction(left);
27848 6718 }
27849
2/2
✓ Branch 0 taken 14280016 times.
✓ Branch 1 taken 7139 times.
14287155 if (y > world_h-16)
27850 {
27851 7139 y = world_h-16;
27852 7139 do_scroll_direction(down);
27853 7139 }
27854
2/2
✓ Branch 0 taken 14278365 times.
✓ Branch 1 taken 8790 times.
14287155 if (y < 0)
27855 {
27856 8790 y = 0;
27857 8790 do_scroll_direction(up);
27858 8790 }
27859 14307783 }
27860
27861 14303885 bool HeroClass::check_prescroll()
27862 {
27863
2/2
✓ Branch 0 taken 14292691 times.
✓ Branch 1 taken 11194 times.
14303885 if(get_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL))
27864 14292691 return true; // skip checks
27865
8/8
✓ Branch 0 taken 11188 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 11185 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11182 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 11180 times.
11194 if (x <= world_w-16 && x >= 0 && y <= world_h-16 && y >= 0)
27866 11180 return true; // in bounds, no need for checks
27867 14 zfix tx = x, ty = y, tz = z;
27868 14 x = vbound(x, 0, world_w-16);
27869 14 y = vbound(y, 0, world_h-16);
27870
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(onWater(true) || drownclk)
27871 return false; // would drown before scrolling
27872
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(pitslide() || fallclk)
27873 return false; // would fall before scrolling
27874 14 x = tx; y = ty; z = tz;
27875 14 return true;
27876 14303885 }
27877
27878 // assumes current direction is in lastdir[3]
27879 // compares directions with scr->path and scr->exitdir
27880 107710 bool HeroClass::checkmaze(const mapscr *scr, bool sound)
27881 {
27882
2/2
✓ Branch 0 taken 106989 times.
✓ Branch 1 taken 721 times.
107710 if(!(scr->flags&fMAZE))
27883 106989 return true;
27884
27885
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 636 times.
721 if(lastdir[3]==scr->exitdir)
27886 85 return true;
27887
27888
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 99 times.
1113 for(int32_t i=0; i<4; i++)
27889
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 537 times.
1014 if(lastdir[i]!=scr->path[i])
27890 537 return false;
27891
27892
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 33 times.
99 if(sound)
27893 33 sfx(scr->secretsfx);
27894
27895 99 return true;
27896 107710 }
27897
27898 // assumes current direction is in lastdir[3]
27899 // compares directions with scr->path and scr->exitdir
27900 38 bool HeroClass::checkmaze_ignore_exit(const mapscr *scr, bool sound)
27901 {
27902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!(scr->flags&fMAZE))
27903 return true;
27904
27905
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 6 times.
64 for(int32_t i=0; i<4; i++)
27906
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 32 times.
58 if(lastdir[i]!=scr->path[i])
27907 32 return false;
27908
27909
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(sound)
27910 6 sfx(scr->secretsfx);
27911
27912 6 return true;
27913 38 }
27914
27915 54046 bool HeroClass::edge_of_dmap(int32_t side)
27916 {
27917
4/4
✓ Branch 0 taken 53862 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 53643 times.
✓ Branch 3 taken 219 times.
54046 if (!has_advanced_maze(origin_scr) && checkmaze(origin_scr, false) == false)
27918 219 return false;
27919
27920 // needs fixin'
27921 // should check dmap style
27922
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15590 times.
✓ Branch 2 taken 11430 times.
✓ Branch 3 taken 12656 times.
✓ Branch 4 taken 14151 times.
53827 switch(side)
27923 {
27924 case up:
27925 15590 return hero_screen<16;
27926
27927 case down:
27928 11430 return hero_screen>=112;
27929
27930 case left:
27931
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 135 times.
12656 if((hero_screen&15)==0)
27932 135 return true;
27933
27934
2/2
✓ Branch 0 taken 7109 times.
✓ Branch 1 taken 5412 times.
12521 if((DMaps[cur_dmap].type&dmfTYPE)!=dmOVERW)
27935 // if(dlevel)
27936 7109 return (((hero_screen&15)-DMaps[cur_dmap].xoff)<=0);
27937
27938 5412 break;
27939
27940 case right:
27941
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14039 times.
14151 if((hero_screen&15)==15)
27942 112 return true;
27943
27944
2/2
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 6202 times.
14039 if((DMaps[cur_dmap].type&dmfTYPE)!=dmOVERW)
27945 // if(dlevel)
27946 7837 return (((hero_screen&15)-DMaps[cur_dmap].xoff)>=7);
27947
27948 6202 break;
27949 }
27950
27951 11614 return false;
27952 54046 }
27953
27954 111816 static std::pair<int, int> lookahead_coords(int scrolldir, int x, int y)
27955 {
27956 111816 x = vbound(x, 0, world_w - 16);
27957 111816 y = vbound(y, 0, world_h - 16);
27958 111816 return {x, y};
27959 }
27960
27961 // Helper for scrollscr that gets next combo on next screen.
27962 27954 static int32_t lookahead(int32_t scrolldir, int x, int y)
27963 {
27964 55908 auto [cx, cy] = lookahead_coords(scrolldir, x, y);
27965 55908 return MAPCOMBO(cx, cy);
27966 }
27967
27968 454 static bool lookaheadraftflag(int scroll_dir, int x, int y)
27969 {
27970 454 int cx = x;
27971 454 int cy = y + 8;
27972 454 bound(cx, 0, world_w - 16);
27973 454 bound(cy, 0, world_h - 8);
27974
27975 454 auto rpos_handle = get_rpos_handle_for_world_xy(cx, cy, 0);
27976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 return (isRaftFlag(rpos_handle.cflag()) || isRaftFlag(rpos_handle.sflag()));
27977 }
27978
27979 3267836 void HeroClass::run_scrolling_script_int(bool waitdraw)
27980 {
27981
2/2
✓ Branch 0 taken 1632996 times.
✓ Branch 1 taken 1634840 times.
3267836 if(waitdraw)
27982 {
27983
3/4
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1143144 times.
✓ Branch 3 taken 489852 times.
1632996 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
27984 {
27985 489852 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
27986 489852 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
27987 489852 }
27988 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
27989
5/6
✓ Branch 0 taken 1632339 times.
✓ Branch 1 taken 657 times.
✓ Branch 2 taken 48739 times.
✓ Branch 3 taken 1583600 times.
✓ Branch 4 taken 48739 times.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27990 {
27991 48739 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
27992 48739 FFCore.waitdraw(ScriptType::Hero) = false;
27993 48739 }
27994 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
27995
4/6
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5575 times.
✓ Branch 3 taken 1627421 times.
✓ Branch 4 taken 5575 times.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27996 {
27997 5575 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
27998 5575 FFCore.waitdraw(ScriptType::DMap) = false;
27999 5575 }
28000 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28001
2/6
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1632996 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28002 {
28003 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
28004 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28005 }
28006 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28007
28008
4/4
✓ Branch 0 taken 123494 times.
✓ Branch 1 taken 1509502 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 122904 times.
1632996 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
28009 {
28010 298738 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
28011
5/6
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 173450 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 1984 times.
✓ Branch 4 taken 400 times.
✗ Branch 5 not taken.
175834 if (scr->script != 0 && FFCore.waitdraw(ScriptType::Screen, scr->screen) && scr->preloadscript)
28012 {
28013 400 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
28014 400 FFCore.waitdraw(ScriptType::Screen, scr->screen) = 0;
28015 400 }
28016 175834 });
28017 122904 }
28018 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1632996 times.
1632996 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
28020 {
28021 1632996 FFCore.itemScriptEngineOnWaitdraw();
28022 1632996 }
28023 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28024 1632996 }
28025 else
28026 {
28027
4/4
✓ Branch 0 taken 125338 times.
✓ Branch 1 taken 1509502 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 124748 times.
1634840 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
28028 {
28029 303202 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
28030
4/4
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 176026 times.
✓ Branch 2 taken 1403 times.
✓ Branch 3 taken 1025 times.
178454 if (scr->script != 0 && scr->preloadscript)
28031 {
28032 1403 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
28033 1403 }
28034 178454 });
28035 124748 }
28036 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
28037
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1091695 times.
✓ Branch 3 taken 543145 times.
1634840 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28038 {
28039 543145 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28040 543145 }
28041 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
28042
6/6
✓ Branch 0 taken 1634182 times.
✓ Branch 1 taken 658 times.
✓ Branch 2 taken 1558716 times.
✓ Branch 3 taken 75466 times.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 49214 times.
1634840 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
28043 {
28044 49214 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
28045 49214 }
28046 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
28047
5/6
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1634248 times.
✓ Branch 3 taken 592 times.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 124746 times.
1634840 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28048 {
28049 124746 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
28050 124746 }
28051 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
28052
4/6
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1634840 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 125338 times.
1634840 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28053 {
28054 125338 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
28055 125338 }
28056 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
28057 1634840 bool old = get_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING);
28058
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68390 times.
✓ Branch 3 taken 1566450 times.
1634840 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
28059 1566450 FFCore.itemScriptEngine();
28060 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
28061
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1566450 times.
✓ Branch 3 taken 68390 times.
1634840 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
28062 68390 FFCore.itemScriptEngine();
28063 }
28064 3267836 }
28065
28066 832 static zfix new_hero_x, new_hero_y;
28067 static int new_region_offset_x, new_region_offset_y;
28068 static region_t scrolling_new_region;
28069
28070 3234993 void HeroClass::run_scrolling_script_old(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28071 {
28072 // For rafting (and possibly other esoteric things)
28073 // Hero's action should remain unchanged while scrolling,
28074 // but for the sake of scripts, here's an eye-watering kludge.
28075 3234993 actiontype lastaction = action;
28076 3234993 action=scrolling; FFCore.setHeroAction(scrolling);
28077
2/2
✓ Branch 0 taken 1616683 times.
✓ Branch 1 taken 1618310 times.
3234993 if(waitdraw)
28078 {
28079 1616683 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28080 1616683 }
28081 else
28082 {
28083 1618310 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28084 }
28085
28086 // Also, hero coordinates should remain unchanged.
28087 // For compat, this is happening after the generic scripts above...
28088 3234993 zfix storex = x, storey = y;
28089
28090
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 811700 times.
✓ Branch 2 taken 584957 times.
✓ Branch 3 taken 858345 times.
✓ Branch 4 taken 979991 times.
3234993 switch(scrolldir)
28091 {
28092 case up:
28093
2/2
✓ Branch 0 taken 669768 times.
✓ Branch 1 taken 141932 times.
811700 if(y < scrolling_new_region.height - 16) y = scrolling_new_region.height;
28094
4/4
✓ Branch 0 taken 118844 times.
✓ Branch 1 taken 23088 times.
✓ Branch 2 taken 52878 times.
✓ Branch 3 taken 65966 times.
141932 else if(cx > 0 && !end_frames) y = sy + scrolling_new_region.height - 20;
28095 75966 else y = scrolling_new_region.height - 16;
28096
28097 811700 x = new_hero_x;
28098 811700 break;
28099
28100 case down:
28101
2/2
✓ Branch 0 taken 476279 times.
✓ Branch 1 taken 108678 times.
584957 if(y > 0) y = -16;
28102
4/4
✓ Branch 0 taken 90765 times.
✓ Branch 1 taken 17913 times.
✓ Branch 2 taken 40026 times.
✓ Branch 3 taken 50739 times.
108678 else if(cx > 0 && !end_frames) y = sy - 172;
28103 57939 else y = 0;
28104
28105 584957 x = new_hero_x;
28106 584957 break;
28107
28108 case left:
28109
2/2
✓ Branch 0 taken 786764 times.
✓ Branch 1 taken 71581 times.
858345 if(x < scrolling_new_region.width - 16) x = scrolling_new_region.width;
28110
2/2
✓ Branch 0 taken 58288 times.
✓ Branch 1 taken 13293 times.
71581 else if(cx > 0) x = sx + scrolling_new_region.width - 20;
28111 13293 else x = scrolling_new_region.width - 16;
28112
28113 858345 y = new_hero_y;
28114 858345 break;
28115
28116 case right:
28117
2/2
✓ Branch 0 taken 898481 times.
✓ Branch 1 taken 81510 times.
979991 if(x > 0) x = -16;
28118
2/2
✓ Branch 0 taken 66446 times.
✓ Branch 1 taken 15064 times.
81510 else if(cx > 0) x = sx - 252;
28119 15064 else x = 0;
28120
28121 979991 y = new_hero_y;
28122 979991 break;
28123 }
28124
28125 3234993 viewport.x -= new_region_offset_x;
28126 3234993 viewport.y -= new_region_offset_y;
28127
28128 3234993 run_scrolling_script_int(waitdraw);
28129
28130 3234993 viewport.x += new_region_offset_x;
28131 3234993 viewport.y += new_region_offset_y;
28132
28133 3234993 x = storex, y = storey;
28134 3234993 action=lastaction; FFCore.setHeroAction(lastaction);
28135 3234993 }
28136
28137 3267836 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28138 {
28139
2/2
✓ Branch 0 taken 3234993 times.
✓ Branch 1 taken 32843 times.
3267836 if (get_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION))
28140 {
28141 // Old code has an off-by-one error, and doesn't clamp the hero position to the viewport.
28142 //
28143 // Although this is behind a compat qr, most test replays wouldn't fail. The ones that do are:
28144 //
28145 // nargads: different sfx plays during last frames of scrolling, sometimes
28146 // crucible: fog is slightly different on last frames of scrolling
28147 // yuurand: breaks. blocks are not removed when returning to a screen during scroll
28148 3234993 run_scrolling_script_old(scrolldir, cx, sx, sy, end_frames, waitdraw);
28149 3234993 return;
28150 }
28151
28152 // For rafting (and possibly other esoteric things)
28153 // Hero's action should remain unchanged while scrolling,
28154 // but for the sake of scripts, here's an eye-watering kludge.
28155 32843 actiontype lastaction = action;
28156 32843 action=scrolling; FFCore.setHeroAction(scrolling);
28157
28158 // Also, hero coordinates should remain unchanged.
28159 32843 zfix storex = x, storey = y;
28160
28161
2/2
✓ Branch 0 taken 16313 times.
✓ Branch 1 taken 16530 times.
32843 if(waitdraw)
28162 {
28163 16313 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28164 16313 }
28165 else
28166 {
28167 16530 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28168 }
28169
28170
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4418 times.
✓ Branch 2 taken 4873 times.
✓ Branch 3 taken 11065 times.
✓ Branch 4 taken 12487 times.
32843 switch(scrolldir)
28171 {
28172 case up:
28173
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4290 times.
4418 if(y <= scrolling_new_region.height - 16) y = scrolling_new_region.height;
28174 128 else y = scrolling_new_region.height - 16;
28175
28176 4418 x = new_hero_x;
28177 4418 break;
28178
28179 case down:
28180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4873 times.
4873 if(y >= 0) y = -16;
28181 else y = 0;
28182
28183 4873 x = new_hero_x;
28184 4873 break;
28185
28186 case left:
28187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11065 times.
11065 if(x <= scrolling_new_region.width - 16) x = scrolling_new_region.width;
28188 else x = scrolling_new_region.width - 16;
28189
28190 11065 y = new_hero_y;
28191 11065 break;
28192
28193 case right:
28194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12487 times.
12487 if(x >= 0) x = -16;
28195 else x = 0;
28196
28197 12487 y = new_hero_y;
28198 12487 break;
28199 }
28200
28201 32843 viewport.x -= new_region_offset_x;
28202 32843 viewport.y -= new_region_offset_y;
28203
28204
4/4
✓ Branch 0 taken 21778 times.
✓ Branch 1 taken 11065 times.
✓ Branch 2 taken 12487 times.
✓ Branch 3 taken 9291 times.
32843 if (scrolldir == left || scrolldir == right)
28205 23552 x.doClamp(viewport.left(), viewport.right() - 16);
28206
4/4
✓ Branch 0 taken 28425 times.
✓ Branch 1 taken 4418 times.
✓ Branch 2 taken 4873 times.
✓ Branch 3 taken 23552 times.
32843 if (scrolldir == up || scrolldir == down)
28207 9291 y.doClamp(viewport.top(), viewport.bottom() - 16);
28208
28209 32843 run_scrolling_script_int(waitdraw);
28210
28211 32843 viewport.x += new_region_offset_x;
28212 32843 viewport.y += new_region_offset_y;
28213
28214 32843 x = storex, y = storey;
28215 32843 action=lastaction; FFCore.setHeroAction(lastaction);
28216 3267836 }
28217
28218 //Has solving the maze enabled a side warp?
28219 //Only used just before scrolling screens
28220 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
28221 // return true to abort the topmost scrollscr() call. -L
28222 27888 bool HeroClass::maze_enabled_sizewarp(const mapscr *scr, int32_t scrolldir)
28223 {
28224 27888 maze_state.last_check_herox = x;
28225 27888 maze_state.last_check_heroy = y;
28226
28227
2/2
✓ Branch 0 taken 83664 times.
✓ Branch 1 taken 27888 times.
111552 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
28228
28229
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 27620 times.
27888 lastdir[3] = scr->flags&fMAZE ? scrolldir : 0xFF;
28230
28231
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27888 if(scr->flags8&fMAZEvSIDEWARP && scr->flags&fMAZE && scrolldir != scr->exitdir)
28232 {
28233 switch(scrolldir)
28234 {
28235 case up:
28236 if(scr->flags2&wfUP && checkmaze(scr,true))
28237 {
28238 lastdir[3] = 0xFF;
28239 sdir=up;
28240 dowarp(scr,1,(scr->sidewarpindex)&3);
28241 return true;
28242 }
28243
28244 break;
28245
28246 case down:
28247 if(scr->flags2&wfDOWN && checkmaze(scr,true))
28248 {
28249 lastdir[3] = 0xFF;
28250 sdir=down;
28251 dowarp(scr,1,(scr->sidewarpindex>>2)&3);
28252 return true;
28253 }
28254
28255 break;
28256
28257 case left:
28258 if(scr->flags2&wfLEFT && checkmaze(scr,true))
28259 {
28260 lastdir[3] = 0xFF;
28261 sdir=left;
28262 dowarp(scr,1,(scr->sidewarpindex>>4)&3);
28263 return true;
28264 }
28265
28266 break;
28267
28268 case right:
28269 if(scr->flags2&wfRIGHT && checkmaze(scr,true))
28270 {
28271 lastdir[3] = 0xFF;
28272 sdir=right;
28273 dowarp(scr,1,(scr->sidewarpindex)&3);
28274 return true;
28275 }
28276
28277 break;
28278 }
28279 }
28280
28281 27888 return false;
28282 27888 }
28283
28284 27954 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
28285 {
28286 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
28287
2/2
✓ Branch 0 taken 2578 times.
✓ Branch 1 taken 25376 times.
27954 if(get_qr(qr_VERYFASTSCROLLING))
28288 2578 return 16;
28289
28290
2/2
✓ Branch 0 taken 23917 times.
✓ Branch 1 taken 1459 times.
25376 if(get_qr(qr_SMOOTHVERTICALSCROLLING) != 0)
28291 {
28292
2/2
✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 7986 times.
23917 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28293 }
28294 else
28295 {
28296
4/4
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 778 times.
1459 if(scrolldir == up || scrolldir == down)
28297 {
28298 681 return 8;
28299 }
28300 else
28301 {
28302
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 437 times.
778 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28303 }
28304 }
28305 27954 }
28306
28307 27954 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
28308 {
28309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 if(get_qr(qr_NOSCROLL))
28310 return 0;
28311
28312
4/4
✓ Branch 0 taken 25376 times.
✓ Branch 1 taken 2578 times.
✓ Branch 2 taken 23917 times.
✓ Branch 3 taken 1459 times.
27954 if( (get_qr(qr_VERYFASTSCROLLING) != 0) ||
28313 25376 (get_qr(qr_SMOOTHVERTICALSCROLLING) != 0) )
28314 {
28315 26495 return 1;
28316 }
28317 else
28318 {
28319
4/4
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 778 times.
1459 if(scrolldir == up || scrolldir == down)
28320 {
28321
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 322 times.
681 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 4 : 2;
28322 }
28323 else
28324 {
28325 778 return 1;
28326 }
28327 }
28328 27954 }
28329
28330 254177 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1)
28331 {
28332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254177 times.
254177 if(!get_qr(qr_NEW_DARKROOM)) return;
28333 254177 int32_t lampid = current_item_id(itype_lantern);
28334
2/2
✓ Branch 0 taken 248624 times.
✓ Branch 1 taken 5553 times.
254177 if(lampid < 0) return;
28335
2/4
✓ Branch 0 taken 248624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248624 times.
248624 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
28336 {
28337 lamp_paid = false;
28338 return;
28339 }
28340 248624 lamp_paid = true;
28341 248624 paymagiccost(lampid,false,true);
28342
28343 248624 int32_t hx = x.getInt() - x1 + 8;
28344 248624 int32_t hy = y.getInt() - y1 + 8;
28345
28346 248624 itemdata& lamp = itemsbuf[lampid];
28347 248624 optional<word> wave_opt;
28348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248624 times.
248624 if(lamp.flags & item_flag1)
28349 wave_opt = 0; // cancel wave effect
28350 248624 handle_lighting(hx, hy, lamp.misc1, lamp.misc2, dir, darkscr_bmp, NULL, -1, -1, -1, -1, wave_opt, wave_opt);
28351 254177 }
28352
28353 struct nearby_scrolling_screen_t
28354 {
28355 int screen;
28356 int offx;
28357 int offy;
28358 bool is_new;
28359 screen_handles_t screen_handles;
28360 };
28361
28362 struct rect_t
28363 {
28364 int l, r, t, b;
28365
28366 rect_t() = default;
28367 111941 explicit rect_t(const viewport_t& viewport) : l(viewport.left()), r(viewport.right()), t(viewport.top()), b(viewport.bottom()) {}
28368
28369 42 void union_with(const rect_t& other)
28370 {
28371 42 l = std::min(l, other.l);
28372 42 r = std::max(r, other.r);
28373 42 t = std::min(t, other.t);
28374 42 b = std::max(b, other.b);
28375 42 }
28376
28377 55908 void intersect_with(const rect_t& other)
28378 {
28379 55908 l = std::max(l, other.l);
28380 55908 r = std::min(r, other.r);
28381 55908 t = std::max(t, other.t);
28382 55908 b = std::min(b, other.b);
28383
28384
2/4
✓ Branch 0 taken 55908 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55908 times.
55908 if (l > r || t > b)
28385 l = r = t = b = 0;
28386 55908 }
28387
28388 125 bool intersects_with(const rect_t& other) const
28389 {
28390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 return std::max(t, other.t) < std::min(b, other.b) && std::max(l, other.l) < std::min(r, other.r);
28391 }
28392
28393 55908 int left() const {return l;}
28394 55908 int right() const {return r;}
28395 55908 int top() const {return t;}
28396 55908 int bottom() const {return b;}
28397 };
28398
28399 struct nearby_scrolling_screens_t
28400 {
28401 std::vector<nearby_scrolling_screen_t> screens;
28402 // Only ever true during whistle warp scrolling.
28403 bool has_overlapping_screens;
28404 rect_t old_screens_rect;
28405 rect_t new_screens_rect;
28406 };
28407
28408 // Returns all the screens (old and new region) that need to be rendered during scrolling, along
28409 // with thier draw offsets.
28410 // Note: The destination screen is hero_screen, the starting screen is scrolling_hero_screen.
28411 // old_viewport_start: the viewport in the old region at start of scrolling
28412 // new_viewport_final: the viewport in the new region at end of scrolling
28413 // old_region_visible: the viewport in the old region that will be visible
28414 // new_region_visible: the viewport in the new region that will be visible
28415 27954 static nearby_scrolling_screens_t get_nearby_scrolling_screens(const std::vector<mapscr*>& old_temporary_screens, viewport_t old_viewport_start, viewport_t new_viewport_final, rect_t old_region_visible, rect_t new_region_visible)
28416 {
28417 27954 bool is_whistle_warp_scroll = HeroInOutgoingWhistleWarp();
28418 27954 int old_region = get_region_id(scrolling_map, scrolling_hero_screen);
28419
28420 27954 nearby_scrolling_screens_t nearby_screens{};
28421 27954 nearby_screens.has_overlapping_screens = is_whistle_warp_scroll;
28422
28423 // base_scr, use_new_screens, offx, offy
28424 27954 std::vector<std::tuple<mapscr*, bool, int, int>> old_screen_deltas;
28425 27954 std::vector<std::tuple<mapscr*, bool, int, int>> new_screen_deltas;
28426
28427
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_x0 = std::clamp(old_region_visible.left() / 256, 0, 15);
28428
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_x1 = std::clamp((old_region_visible.right() - 1) / 256, 0, 15);
28429
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_y0 = std::clamp(old_region_visible.top() / 176, 0, 8);
28430
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_y1 = std::clamp((old_region_visible.bottom() - 1) / 176, 0, 8);
28431
2/2
✓ Branch 0 taken 27980 times.
✓ Branch 1 taken 27954 times.
55934 for (int x = old_screens_x0; x <= old_screens_x1; x++)
28432 {
28433
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 27980 times.
56116 for (int y = old_screens_y0; y <= old_screens_y1; y++)
28434 {
28435 28136 int screen = scrolling_region.origin_screen + x + y*16;
28436
2/4
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28136 times.
28136 if (get_region_id(scrolling_map, screen) != old_region)
28437 continue;
28438
28439 28136 mapscr* base_scr = old_temporary_screens[screen*7];
28440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28136 CHECK(base_scr);
28441 28136 bool use_new_screens = false;
28442 28136 int offx = get_region_relative_dx(screen, scrolling_region.origin_screen) * 256;
28443 28136 int offy = get_region_relative_dy(screen, scrolling_region.origin_screen) * 176;
28444
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 old_screen_deltas.push_back({base_scr, use_new_screens, offx, offy});
28445 28136 }
28446 27980 }
28447
28448 // This translates from the new region to the old region's coordinates ...
28449 int dx, dy;
28450
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (is_whistle_warp_scroll)
28451 {
28452 // ... anchored at the current viewport.
28453
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if (scrolling_dir == right)
28454
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 dx = old_viewport_start.right() - new_viewport_final.right();
28455 else
28456
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 dx = old_viewport_start.left() - new_viewport_final.left();
28457
28458
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 119 times.
125 if (scrolling_dir == up)
28459
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 dy = old_viewport_start.bottom() - new_viewport_final.bottom();
28460 else
28461
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 dy = old_viewport_start.top() - new_viewport_final.top();
28462
28463
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6 times.
125 if (scrolling_dir == up) dy -= old_viewport_start.h;
28464
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 115 times.
119 else if (scrolling_dir == down) dy += old_viewport_start.h;
28465
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 113 times.
115 else if (scrolling_dir == left) dx -= old_viewport_start.w;
28466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 else if (scrolling_dir == right) dx += old_viewport_start.w;
28467 125 }
28468 else
28469 {
28470 // ... anchored at the point where the screen scrolling starts.
28471 55658 dx = get_region_relative_dx(cur_screen, scrolling_region.origin_screen) -
28472 27829 (get_region_relative_dx(hero_screen, scrolling_region.origin_screen) - get_region_relative_dx(scrolling_hero_screen, scrolling_region.origin_screen));
28473 55658 dy = get_region_relative_dy(cur_screen, scrolling_region.origin_screen) -
28474 27829 (get_region_relative_dy(hero_screen, scrolling_region.origin_screen) - get_region_relative_dy(scrolling_hero_screen, scrolling_region.origin_screen));
28475
2/2
✓ Branch 0 taken 19757 times.
✓ Branch 1 taken 8072 times.
27829 if (scrolling_dir == up) dy -= 1;
28476
2/2
✓ Branch 0 taken 5951 times.
✓ Branch 1 taken 13806 times.
19757 else if (scrolling_dir == down) dy += 1;
28477
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 7288 times.
13806 else if (scrolling_dir == left) dx -= 1;
28478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7288 times.
7288 else if (scrolling_dir == right) dx += 1;
28479 27829 dx *= 256;
28480 27829 dy *= 176;
28481 }
28482
28483
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_x0 = std::clamp(new_region_visible.left() / 256, 0, 15);
28484
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_x1 = std::clamp((new_region_visible.right() - 1) / 256, 0, 15);
28485
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_y0 = std::clamp(new_region_visible.top() / 176, 0, 8);
28486
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_y1 = std::clamp((new_region_visible.bottom() - 1) / 176, 0, 8);
28487
28488
2/2
✓ Branch 0 taken 27982 times.
✓ Branch 1 taken 27954 times.
55936 for (int x = new_screens_x0; x <= new_screens_x1; x++)
28489 {
28490
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 27982 times.
56118 for (int y = new_screens_y0; y <= new_screens_y1; y++)
28491 {
28492 28136 int screen = cur_screen + x + y*16;
28493
2/4
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28136 times.
✗ Branch 3 not taken.
28136 if (!is_in_current_region(screen))
28494 continue;
28495
28496 28136 int sx = get_region_relative_dx(screen, cur_screen);
28497 28136 int sy = get_region_relative_dy(screen, cur_screen);
28498 28136 int offx = sx * 256 + dx;
28499 28136 int offy = sy * 176 + dy;
28500
28501
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 mapscr* base_scr = get_scr(cur_map, screen);
28502 28136 bool use_new_screens = true;
28503
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 new_screen_deltas.push_back({base_scr, use_new_screens, offx, offy});
28504 28136 }
28505 27982 }
28506
28507 // First handle the old screens, then the new screens.
28508 27954 std::vector<std::tuple<mapscr*, bool, int, int>> screen_deltas;
28509
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 screen_deltas.insert(screen_deltas.end(), old_screen_deltas.begin(), old_screen_deltas.end());
28510
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 screen_deltas.insert(screen_deltas.end(), new_screen_deltas.begin(), new_screen_deltas.end());
28511
28512
2/2
✓ Branch 0 taken 56272 times.
✓ Branch 1 taken 27954 times.
84226 for (const auto& pair : screen_deltas)
28513 {
28514 56272 mapscr* base_scr = std::get<0>(pair);
28515 56272 bool use_new_screens = std::get<1>(pair);
28516 56272 int offx = std::get<2>(pair);
28517 56272 int offy = std::get<3>(pair);
28518
28519 56272 int screen = base_scr->screen;
28520 56272 int map = base_scr->map;
28521
28522
1/2
✓ Branch 0 taken 56272 times.
✗ Branch 1 not taken.
56272 auto& nearby_screen = nearby_screens.screens.emplace_back();
28523 56272 nearby_screen.screen = screen;
28524 56272 nearby_screen.offx = offx;
28525 56272 nearby_screen.offy = offy;
28526 56272 nearby_screen.is_new = use_new_screens;
28527
28528 56272 nearby_screen.screen_handles[0] = {base_scr, base_scr, screen, 0};
28529
2/2
✓ Branch 0 taken 337632 times.
✓ Branch 1 taken 56272 times.
393904 for (int i = 1; i <= 6; i++)
28530 {
28531
2/2
✓ Branch 0 taken 168816 times.
✓ Branch 1 taken 168816 times.
506448 mapscr* scr = use_new_screens ?
28532
1/2
✓ Branch 0 taken 168816 times.
✗ Branch 1 not taken.
168816 get_scr_layer(map, screen, i) :
28533 168816 old_temporary_screens[screen*7 + i];
28534
2/2
✓ Branch 0 taken 67989 times.
✓ Branch 1 taken 269643 times.
337632 nearby_screen.screen_handles[i] = {base_scr, scr->is_valid() ? scr : nullptr, screen, i};
28535 337632 }
28536 }
28537
28538 // When old/new screens are possibly overlapping, reduce the drawing clip used for new screens based on the old viewport.
28539
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (nearby_screens.has_overlapping_screens)
28540 {
28541
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 rect_t old_rect = rect_t(old_viewport_start);
28542
28543 125 std::vector<rect_t> new_rects;
28544
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 342 times.
467 for (const auto& nearby_screen : nearby_screens.screens)
28545 {
28546
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 175 times.
342 if (!nearby_screen.is_new)
28547 175 continue;
28548
28549 rect_t rect;
28550 167 rect.l = nearby_screen.offx;
28551 167 rect.r = nearby_screen.offx + 256;
28552 167 rect.t = nearby_screen.offy;
28553 167 rect.b = nearby_screen.offy + 176;
28554
1/2
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
167 new_rects.push_back(rect);
28555 }
28556
28557
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 rect_t new_rect = new_rects.at(0);
28558
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 42 times.
167 for (int i = 1; i < new_rects.size(); i++)
28559
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 new_rect.union_with(new_rects[i]);
28560
28561
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 14 times.
125 if (new_rect.intersects_with(old_rect))
28562 {
28563
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14 if (scrolling_dir == right && new_rect.l < old_rect.r)
28564 2 new_rect.l = old_rect.r + 1;
28565
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
12 else if (scrolling_dir == left && new_rect.r > old_rect.l)
28566 2 new_rect.r = old_rect.l - 1;
28567
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
10 else if (scrolling_dir == up && new_rect.b > old_rect.t)
28568 6 new_rect.b = old_rect.t - 1;
28569
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 else if (scrolling_dir == down && new_rect.t < old_rect.b)
28570 4 new_rect.t = old_rect.b + 1;
28571 14 }
28572
28573 125 nearby_screens.old_screens_rect = old_rect;
28574 125 nearby_screens.new_screens_rect = new_rect;
28575 125 }
28576
28577 27954 return nearby_screens;
28578
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 }
28579
28580 24821514 static void for_every_nearby_screen_during_scroll(
28581 const nearby_scrolling_screens_t& nearby_screens,
28582 const std::function <void (screen_handles_t, int, int, int, bool)>& fn)
28583 {
28584
2/2
✓ Branch 0 taken 129282 times.
✓ Branch 1 taken 24692232 times.
24821514 if (!nearby_screens.has_overlapping_screens)
28585 {
28586
2/2
✓ Branch 0 taken 49849496 times.
✓ Branch 1 taken 24692232 times.
74541728 for (const auto& nearby_screen : nearby_screens.screens)
28587 49849496 fn(nearby_screen.screen_handles, nearby_screen.screen, nearby_screen.offx, nearby_screen.offy, nearby_screen.is_new);
28588 24692232 return;
28589 }
28590
28591 129282 int cl = framebuf->cl;
28592 129282 int cr = framebuf->cr;
28593 129282 int ct = framebuf->ct;
28594 129282 int cb = framebuf->cb;
28595
28596
2/2
✓ Branch 0 taken 129282 times.
✓ Branch 1 taken 395460 times.
524742 for (const auto& nearby_screen : nearby_screens.screens)
28597 {
28598
2/2
✓ Branch 0 taken 191742 times.
✓ Branch 1 taken 203718 times.
395460 auto& rect = nearby_screen.is_new ? nearby_screens.new_screens_rect : nearby_screens.old_screens_rect;
28599 395460 int l = rect.l - viewport.x;
28600 395460 int t = rect.t - viewport.y + playing_field_offset;
28601 395460 int r = rect.r - viewport.x;
28602 395460 int b = rect.b - viewport.y + playing_field_offset;
28603 395460 add_clip_rect(framebuf, l, t, r, b);
28604
28605 395460 fn(nearby_screen.screen_handles, nearby_screen.screen, nearby_screen.offx, nearby_screen.offy, nearby_screen.is_new);
28606
28607 395460 set_clip_rect(framebuf, cl, ct, cr, cb);
28608 }
28609 24821514 }
28610
28611 10406 static void scrollscr_handle_dark(mapscr* newscr, mapscr* oldscr, const nearby_scrolling_screens_t& nearby_screens)
28612 {
28613 extern int dither_offx;
28614 extern int dither_offy;
28615
28616 10406 clear_darkroom_bitmaps();
28617 10406 set_clip_rect(framebuf, 0, playing_field_offset, 256, framebuf->h);
28618
28619
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
32542 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
28620 22136 mapscr* base_scr = screen_handles[0].scr;
28621
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 bool dark = is_new_screen ? is_dark(base_scr) : scrolling_is_dark(base_scr);
28622
2/2
✓ Branch 0 taken 18904 times.
✓ Branch 1 taken 3232 times.
22136 if (!dark)
28623 {
28624 3232 offy += playing_field_offset;
28625 3232 rectfill(darkscr_bmp, offx - viewport.x, offy - viewport.y, offx - viewport.x + 256 - 1, offy - viewport.y + 176 - 1, 0);
28626 3232 rectfill(darkscr_bmp_trans, offx - viewport.x, offy - viewport.y, offx - viewport.x + 256 - 1, offy - viewport.y + 176 - 1, 0);
28627 3232 }
28628 22136 });
28629
28630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10406 times.
32542 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
28631 22136 mapscr* base_scr = screen_handles[0].scr;
28632
28633
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 dither_offx = is_new_screen ? -new_region_offset_x : 0;
28634
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 dither_offy = is_new_screen ? -new_region_offset_y : 0;
28635 22136 calc_darkroom_combos(base_scr, offx, offy + playing_field_offset);
28636
28637
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 int offx2 = is_new_screen ? new_region_offset_x : 0;
28638
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 int offy2 = is_new_screen ? new_region_offset_y : 0;
28639 22136 calc_darkroom_ffcs(base_scr, offx2, offy2 + playing_field_offset);
28640 22136 });
28641
28642 10406 Hero.calc_darkroom_hero(0, -playing_field_offset);
28643 10406 dither_offx = 0;
28644 10406 dither_offy = 0;
28645
28646 10406 do_primitives(framebuf, SPLAYER_DARKROOM_UNDER);
28647 10406 set_clip_rect(framebuf, 0, playing_field_offset, framebuf->w, framebuf->h);
28648
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if (hero_scr->flags9 & fDARK_DITHER) //dither the entire bitmap
28649 {
28650 ditherblit(darkscr_bmp,darkscr_bmp,0,game->get_dither_type(),game->get_dither_arg());
28651 ditherblit(darkscr_bmp_trans,darkscr_bmp_trans,0,game->get_dither_type(),game->get_dither_arg());
28652 }
28653
28654 10406 color_map = &trans_table2;
28655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10406 times.
10406 if(hero_scr->flags9 & fDARK_TRANS) //draw the dark as transparent
28656 {
28657 draw_trans_sprite(framebuf, darkscr_bmp, 0, 0);
28658 if(get_qr(qr_NEWDARK_TRANS_STACKING))
28659 draw_trans_sprite(framebuf, darkscr_bmp_trans, 0, 0);
28660 }
28661 else
28662 {
28663 10406 masked_blit(darkscr_bmp, framebuf, 0, 0, 0, 0, framebuf->w, framebuf->h);
28664 10406 draw_trans_sprite(framebuf, darkscr_bmp_trans, 0, 0);
28665 }
28666 10406 color_map = &trans_table;
28667
28668 10406 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28669 10406 do_primitives(framebuf, SPLAYER_DARKROOM_OVER);
28670 10406 }
28671
28672 17954783 static void do_ffc_scroll_layer(BITMAP* dest, int layer, const nearby_scrolling_screens_t& nearby_screens, int xoff, int yoff)
28673 {
28674
2/2
✓ Branch 0 taken 12779789 times.
✓ Branch 1 taken 5174994 times.
17954783 if(!get_qr(qr_FFCSCROLL))
28675 12779789 return;
28676 // Draw all FFCs from the previous region.
28677
2/2
✓ Branch 0 taken 703799184 times.
✓ Branch 1 taken 5174994 times.
708974178 for (int i = 0; i < FFCore.ScrollingScreensAll.size(); i += 7)
28678 {
28679 703799184 mapscr* scr = FFCore.ScrollingScreensAll[i];
28680
2/2
✓ Branch 0 taken 5763582 times.
✓ Branch 1 taken 698035602 times.
703799184 if (!scr)
28681 698035602 continue;
28682
28683 5763582 auto screen_handle = screen_handle_t{scr, scr, scr->screen, 0};
28684 5763582 do_ffc_layer(dest, layer, screen_handle, 0, 0);
28685 5763582 }
28686
28687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5174994 times.
15811246 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
28688
2/2
✓ Branch 0 taken 5320392 times.
✓ Branch 1 taken 5315860 times.
10636252 if (!is_new_screen)
28689 5320392 return;
28690
28691 5315860 do_ffc_layer(dest, layer, screen_handles[0], xoff, yoff);
28692 10636252 });
28693 17954783 }
28694
28695 27954 void HeroClass::scrollscr(int32_t scrolldir, int32_t dest_screen, int32_t destdmap)
28696 {
28697
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if(action==freeze||action==sideswimfreeze)
28698 {
28699 return;
28700 }
28701
28702 // If on a slope in sideview mode, move along that slope a bit.
28703 27954 zfix sideview_scrolling_slope;
28704
2/2
✓ Branch 0 taken 27051 times.
✓ Branch 1 taken 903 times.
27954 if (sideview_mode())
28705 {
28706 903 y+=2+0.0001_zf;
28707 903 slope_info const& s = get_slope(this, true).get_info();
28708 903 y-=2+0.0001_zf;
28709
28710 903 sideview_scrolling_slope = s.slope();
28711
1/2
✓ Branch 0 taken 903 times.
✗ Branch 1 not taken.
903 if (sideview_scrolling_slope)
28712 {
28713 int dx = 0;
28714 int dy = 0;
28715 if (scrolldir == left)
28716 dx = -1;
28717 else if (scrolldir == right)
28718 dx = 1;
28719 else if (scrolldir == up)
28720 dy = -1;
28721 else if (scrolldir == down)
28722 dy = 1;
28723
28724 // "Ride" the slope for 16 pixels.
28725 for (int i = 0; i < 16; i++)
28726 {
28727 if (scrolldir == left || scrolldir == right)
28728 {
28729 x += dx;
28730 y = s.getY(x + (sideview_scrolling_slope > 0 ? 0 : hit_width)) - hit_height;
28731 }
28732 else
28733 {
28734 x += 1 / sideview_scrolling_slope * dy;
28735 y = s.getY(x + (sideview_scrolling_slope > 0 ? 0 : hit_width)) - hit_height;
28736 }
28737
28738 herostep();
28739 draw_screen();
28740 advanceframe(true);
28741
28742 // Check if the slope the player is on has changed.
28743 y+=2+0.0001_zf;
28744 slope_info const& s = get_slope(this, true).get_info();
28745 y-=2+0.0001_zf;
28746 sideview_scrolling_slope = s.slope();
28747 if (!sideview_scrolling_slope)
28748 break;
28749 }
28750 }
28751 903 }
28752
28753
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if (viewport_mode != ViewportMode::CenterAndBound || get_viewport_sprite() != &Hero)
28754 {
28755 set_viewport_sprite(&Hero);
28756 viewport_mode = ViewportMode::CenterAndBound;
28757 update_viewport();
28758 }
28759
28760 27954 bool overlay = false;
28761
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if(scrolldir >= 0 && scrolldir <= 3)
28762 {
28763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 overlay = get_bit(&(cur_screen >= 128 ? special_warp_return_scr : origin_scr)->sidewarpoverlayflags, scrolldir) ? true : false;
28764 27954 }
28765
28766 27954 int old_dmap = cur_dmap;
28767
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 26926 times.
27954 int new_dmap = destdmap >= 0 ? destdmap : cur_dmap;
28768 27954 int new_map = DMaps[new_dmap].map;
28769
28770 27954 bool updatemusic = FFCore.can_dmap_change_music(destdmap);
28771 27954 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
28772
28773
3/4
✓ Branch 0 taken 27842 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 27842 times.
✗ Branch 3 not taken.
27954 if (!has_advanced_maze(origin_scr) && maze_enabled_sizewarp(origin_scr, scrolldir))
28774 return; // dowarp() was called
28775
28776 27954 int original_destscr = dest_screen;
28777
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 26924 times.
27954 if (dest_screen == -1)
28778 {
28779 26924 dest_screen = hero_screen;
28780
3/4
✓ Branch 0 taken 26765 times.
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26765 times.
26924 if (checkmaze(origin_scr, false) && !edge_of_dmap(scrolldir)) {
28781 26765 dest_screen = screen_index_direction(dest_screen, (direction)scrolldir);
28782 26765 }
28783 26924 }
28784
28785 27954 int old_region_scr_dx = region_scr_dx;
28786 27954 int old_region_scr_dy = region_scr_dy;
28787 27954 int old_world_w = world_w;
28788 27954 int old_world_h = world_h;
28789 27954 int old_original_playing_field_offset = original_playing_field_offset;
28790 27954 viewport_t old_viewport = viewport;
28791 27954 region_t old_region = cur_region;
28792
28793 // Determine what the player position will be after scrolling (within the new screen's coordinate system),
28794 // and what the new viewport will be.
28795 viewport_t new_viewport;
28796 region_t new_region;
28797 int new_scr_dx, new_scr_dy;
28798 56294 auto calc_new_viewport_and_pos = [&](){
28799 28340 calculate_region(new_map, dest_screen, new_region, new_scr_dx, new_scr_dy);
28800
28801 // These mark the top-left coordinate of the new region, in the old region's world coordinates.
28802 28340 new_region_offset_x = (new_region.origin_screen_x - old_region.origin_screen_x)*256;
28803 28340 new_region_offset_y = (new_region.origin_screen_y - old_region.origin_screen_y)*176;
28804
28805 28340 new_hero_x = 0;
28806 28340 new_hero_y = 0;
28807
4/5
✓ Branch 0 taken 6067 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8302 times.
✓ Branch 3 taken 6540 times.
✓ Branch 4 taken 7431 times.
28340 switch (scrolldir)
28808 {
28809 case up:
28810 {
28811 8302 new_hero_x.val = (new_scr_dx - old_region_scr_dx) * 256 * 10000L + x.val;
28812 8302 new_hero_y = new_region.height - 16;
28813 }
28814 8302 break;
28815
28816 case down:
28817 {
28818 6067 new_hero_x.val = (new_scr_dx - old_region_scr_dx) * 256 * 10000L + x.val;
28819 6067 new_hero_y = 0;
28820 }
28821 6067 break;
28822
28823 case left:
28824 {
28825 6540 new_hero_x = new_region.width - 16;
28826 6540 new_hero_y.val = (new_scr_dy - old_region_scr_dy) * 176 * 10000L + y.val;
28827 }
28828 6540 break;
28829
28830 case right:
28831 {
28832 7431 new_hero_x = 0;
28833 7431 new_hero_y.val = (new_scr_dy - old_region_scr_dy) * 176 * 10000L + y.val;
28834 }
28835 7431 break;
28836
28837 // Should never happen ...
28838 default:
28839 {
28840 abort();
28841 }
28842 }
28843
28844 28340 int new_hero_x_for_viewport = new_hero_x;
28845 28340 int new_hero_y_for_viewport = new_hero_y;
28846
28847 // If arriving in a whistle warp, the new viewport will be based on the warp destination instead.
28848
2/2
✓ Branch 0 taken 28215 times.
✓ Branch 1 taken 125 times.
28340 if (HeroInOutgoingWhistleWarp())
28849 {
28850 125 const mapscr* newscr = get_canonical_scr(new_map, dest_screen);
28851
28852
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
28853 42 new_hero_x_for_viewport=newscr->warpreturnx[0];
28854 83 else new_hero_x_for_viewport=newscr->warparrivalx;
28855 125 new_hero_x_for_viewport += new_scr_dx*256;
28856
28857
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
28858 42 new_hero_y_for_viewport=newscr->warpreturny[0];
28859 83 else new_hero_y_for_viewport=newscr->warparrivaly;
28860 125 new_hero_y_for_viewport += new_scr_dy*176;
28861 125 }
28862
28863 28340 new_viewport = {};
28864 28340 calculate_viewport(new_viewport, new_dmap, dest_screen, new_region.width, new_region.height, new_hero_x_for_viewport + Hero.txsz*16/2, new_hero_y_for_viewport + Hero.tysz*16/2);
28865
28866 28340 scrolling_new_region = new_region;
28867 28340 };
28868 27954 calc_new_viewport_and_pos();
28869
28870 27954 int step = get_scroll_step(scrolldir);
28871 27954 int delay = get_scroll_delay(scrolldir);
28872
28873 int scroll_counter, scroll_amount, dx, dy;
28874 int secondary_axis_alignment_amount;
28875 56101 auto calc_scroll_data = [&](){
28876 28147 int scroll_height = std::min(viewport.h, new_viewport.h);
28877 28147 int scroll_width = std::min(viewport.w, new_viewport.w);
28878
4/4
✓ Branch 0 taken 19957 times.
✓ Branch 1 taken 8190 times.
✓ Branch 2 taken 6011 times.
✓ Branch 3 taken 13946 times.
28147 scroll_amount = scrolldir == up || scrolldir == down ? scroll_height : scroll_width;
28879 28147 scroll_counter = scroll_amount / step;
28880
28881 28147 dx = 0;
28882 28147 dy = 0;
28883
2/2
✓ Branch 0 taken 19957 times.
✓ Branch 1 taken 8190 times.
28147 if (scrolldir == up) dy = -1;
28884
2/2
✓ Branch 0 taken 22136 times.
✓ Branch 1 taken 6011 times.
28147 if (scrolldir == down) dy = 1;
28885
2/2
✓ Branch 0 taken 21617 times.
✓ Branch 1 taken 6530 times.
28147 if (scrolldir == left) dx = -1;
28886
2/2
✓ Branch 0 taken 20731 times.
✓ Branch 1 taken 7416 times.
28147 if (scrolldir == right) dx = 1;
28887
28888 // Determine by how much we need to align to the new region's viewport.
28889 // This sets `secondary_axis_alignment_amount` to the number of pixels needed to adjust along the secondary axis
28890 // to move (the position of link relative to the display) from the old viewport to the new viewport.
28891 28147 int old_hero_screen_x = x.getInt() - old_viewport.x;
28892 28147 int old_hero_screen_y = y.getInt() - old_viewport.y + old_original_playing_field_offset;
28893 28147 int new_hero_screen_x = new_hero_x - new_viewport.x;
28894 28147 int new_hero_screen_y = new_hero_y - new_viewport.y + (232 - new_viewport.h);
28895
2/2
✓ Branch 0 taken 13946 times.
✓ Branch 1 taken 14201 times.
28147 if (dx) secondary_axis_alignment_amount = new_hero_screen_y - old_hero_screen_y;
28896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14201 times.
14201 else if (dy) secondary_axis_alignment_amount = new_hero_screen_x - old_hero_screen_x;
28897 else secondary_axis_alignment_amount = 0;
28898
28899
2/2
✓ Branch 0 taken 28022 times.
✓ Branch 1 taken 125 times.
28147 if (HeroInOutgoingWhistleWarp()) secondary_axis_alignment_amount = 0;
28900 28147 };
28901 27954 calc_scroll_data();
28902
28903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27954 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
28904 !(jumping<0 || fall!=0 || fakefall!=0) && get_qr(qr_SIDEVIEWLADDER_FACEUP);
28905
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 if (isForceFaceUp) dir = up;
28906
28907 27954 bool is_unsmooth_vertical_scrolling =
28908
4/4
✓ Branch 0 taken 19876 times.
✓ Branch 1 taken 8078 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 13921 times.
27954 (scrolldir == up || scrolldir == down) && get_qr(qr_SMOOTHVERTICALSCROLLING) == 0;
28909
28910 27954 kill_enemy_sfx();
28911 27954 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28912 27954 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
28913
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8078 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 6520 times.
✓ Branch 4 taken 7401 times.
27954 switch(scrolldir)
28914 {
28915 case up:
28916 8078 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28917 8078 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
28918 8078 break;
28919 case down:
28920 5955 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28921 5955 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
28922 5955 break;
28923 case left:
28924 6520 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
28925 6520 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28926 6520 break;
28927 case right:
28928 7401 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
28929 7401 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28930 7401 break;
28931 }
28932 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_DELTA_X] = new_region_offset_x;
28933 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_DELTA_Y] = new_region_offset_y;
28934 27954 FFCore.ScrollingData[SCROLLDATA_NRX] = new_region_offset_x - viewport.x;
28935 27954 FFCore.ScrollingData[SCROLLDATA_NRY] = new_region_offset_y - viewport.y;
28936 27954 FFCore.ScrollingData[SCROLLDATA_ORX] = -viewport.x;
28937 27954 FFCore.ScrollingData[SCROLLDATA_ORY] = -viewport.y;
28938
28939 // Get the screen coords of the top-left of the screen we are scrolling away from.
28940 111816 auto [old_sx, old_sy] = translate_screen_coordinates_to_world(hero_screen);
28941 27954 FFCore.ScrollingData[SCROLLDATA_OX] = old_sx - viewport.x;
28942 27954 FFCore.ScrollingData[SCROLLDATA_OY] = old_sy - viewport.y;
28943
28944 27954 FFCore.ScrollingData[SCROLLDATA_NEW_SCREEN_X] = new_scr_dx * 256;
28945 27954 FFCore.ScrollingData[SCROLLDATA_NEW_SCREEN_Y] = new_scr_dy * 176;
28946
28947 27954 FFCore.ScrollingData[SCROLLDATA_OLD_SCREEN_X] = old_sx;
28948 27954 FFCore.ScrollingData[SCROLLDATA_OLD_SCREEN_Y] = old_sy;
28949
28950 27954 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
28951 27954 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
28952
28953 27954 FFCore.ScrollingData[SCROLLDATA_OLD_HERO_X] = x.getInt();
28954 27954 FFCore.ScrollingData[SCROLLDATA_OLD_HERO_Y] = y.getInt();
28955
28956 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_SCREEN_WIDTH] = new_region.screen_width;
28957 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_SCREEN_HEIGHT] = new_region.screen_height;
28958
28959 27954 FFCore.ScrollingData[SCROLLDATA_OLD_REGION_SCREEN_WIDTH] = cur_region.screen_width;
28960 27954 FFCore.ScrollingData[SCROLLDATA_OLD_REGION_SCREEN_HEIGHT] = cur_region.screen_height;
28961
28962 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_WIDTH] = new_viewport.w;
28963 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_HEIGHT] = new_viewport.h;
28964
28965 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_WIDTH] = viewport.w;
28966 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_HEIGHT] = viewport.h;
28967
28968 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_X] = new_viewport.x;
28969 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_Y] = new_viewport.y;
28970
28971 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_X] = viewport.x;
28972 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_Y] = viewport.y;
28973
28974 27954 FFCore.clear_combo_scripts();
28975
28976 27954 conveyclk = 2;
28977 27954 screenscrolling = true;
28978 27954 scrolling_dir = (direction) scrolldir;
28979 27954 scrolling_hero_screen = hero_screen;
28980 27954 scrolling_region = cur_region;
28981 27954 scrolling_region_is_lit = region_is_lit;
28982
28983 27954 int32_t scx = get_qr(qr_FASTDNGN) ? 30 : 0;
28984
2/2
✓ Branch 0 taken 25376 times.
✓ Branch 1 taken 2578 times.
27954 if(get_qr(qr_VERYFASTSCROLLING)) //just a minor adjustment.
28985 2578 scx = 32; //for sideview very fast screolling.
28986
28987 27954 auto hero_x_before_scripts = x;
28988 27954 auto hero_y_before_scripts = y;
28989
28990 // Don't signal to scripts that scrolling has "started" (and thus all the Game->Scrolling variables are valid)
28991 // just yet. Store what we calculated and apply them after this next frame.
28992 // TODO(replays): update. And probably just move the calculation to after this frame renders (rather than cache).
28993
11/20
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 27946 times.
✓ Branch 2 taken 27946 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27946 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27946 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 27946 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 27946 times.
✓ Branch 12 taken 8 times.
✓ Branch 13 taken 27946 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
55900 bool crucible_quest_compat = replay_is_debug() && replay_get_meta_str("qst") == "crucible_quest.qst";
28994 int cached_scrolling[SZ_SCROLLDATA];
28995
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27734 times.
27954 if (!crucible_quest_compat)
28996 {
28997
2/2
✓ Branch 0 taken 859754 times.
✓ Branch 1 taken 27734 times.
887488 for (int i = 0; i < SZ_SCROLLDATA; i++)
28998 859754 cached_scrolling[i] = FFCore.ScrollingData[i];
28999 27734 memset(FFCore.ScrollingData, 0, sizeof(int32_t) * SZ_SCROLLDATA);
29000 27734 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
29001 27734 }
29002
29003 // Wait one frame. This still uses the old region's coordinates.
29004 27954 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging;
29005 27954 bool lasttapping = tapping;
29006 27954 actiontype lastaction = action;
29007 {
29008 27954 ALLOFF(false, false);
29009 // for now, restore Hero's previous action
29010
2/2
✓ Branch 0 taken 26070 times.
✓ Branch 1 taken 1884 times.
27954 if(!get_qr(qr_SCROLLING_KILLS_CHARGE))
29011 1884 charging = lastcharging;
29012
2/2
✓ Branch 0 taken 9244 times.
✓ Branch 1 taken 18710 times.
27954 if (replay_version_check(0, 28))
29013 {
29014 // nargads_trail_crystal_crusades replay tests need this.
29015
2/2
✓ Branch 0 taken 18436 times.
✓ Branch 1 taken 274 times.
18710 if(!get_qr(qr_SCROLLING_KILLS_CHARGE)) attackclk = lastattackclk;
29016 18710 spins = lastspins; charging = lastcharging; tapping = lasttapping;
29017 18710 }
29018
29019 27954 action=lastaction; FFCore.setHeroAction(lastaction);
29020
29021 27954 lstep = (lstep + 6) % 12;
29022 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
29023
3/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18377 times.
✓ Branch 3 taken 9577 times.
27954 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
29024 {
29025 9577 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
29026 9577 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
29027 9577 }
29028 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
29029
5/6
✓ Branch 0 taken 27943 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1099 times.
✓ Branch 3 taken 26844 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1099 times.
27954 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29030 {
29031 1099 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
29032 1099 FFCore.waitdraw(ScriptType::Hero) = false;
29033 1099 }
29034 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
29035
4/6
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 27862 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 92 times.
27954 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29036 {
29037 92 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
29038 92 FFCore.waitdraw(ScriptType::DMap) = false;
29039 92 }
29040 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
29041
2/6
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27954 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29042 {
29043 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
29044 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
29045 }
29046 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
29047
29048
4/4
✓ Branch 0 taken 3213 times.
✓ Branch 1 taken 24741 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3203 times.
27954 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
29049 {
29050 7178 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
29051
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 3950 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
3975 if (scr->script != 0 && FFCore.waitdraw(ScriptType::Screen, scr->screen))
29052 {
29053 14 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
29054 14 FFCore.waitdraw(ScriptType::Screen, scr->screen) = 0;
29055 14 }
29056 3975 });
29057 3203 }
29058 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
29059
29060 889134 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
29061
4/4
✓ Branch 0 taken 12511 times.
✓ Branch 1 taken 848669 times.
✓ Branch 2 taken 12487 times.
✓ Branch 3 taken 24 times.
861180 if (ffc_handle.ffc->script != 0 && FFCore.waitdraw(ScriptType::FFC, ffc_handle.id))
29062 {
29063 24 ZScriptVersion::RunScript(ScriptType::FFC, ffc_handle.ffc->script, ffc_handle.id);
29064 24 FFCore.waitdraw(ScriptType::FFC, ffc_handle.id) = false;
29065 24 }
29066 861180 });
29067
29068 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
29069 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
29070 //Waitdraw for item scripts.
29071 27954 FFCore.itemScriptEngineOnWaitdraw();
29072 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
29073 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
29074
29075 //Sprite scripts on Waitdraw
29076 27954 FFCore.eweaponScriptEngineOnWaitdraw();
29077 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
29078 27954 FFCore.itemSpriteScriptEngineOnWaitdraw();
29079 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
29080
29081 //This is no longer a do-while, as the first iteration is now slightly different. -Em
29082 27954 draw_screen(true,true);
29083
29084 27954 rehydratelake(false);
29085
29086 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29087 }
29088
29089 27954 advanceframe(true);
29090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 if(Quit)
29091 {
29092 screenscrolling = false;
29093 return;
29094 }
29095
29096
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27734 times.
27954 if (!crucible_quest_compat)
29097 {
29098
2/2
✓ Branch 0 taken 859754 times.
✓ Branch 1 taken 27734 times.
887488 for (int i = 0; i < SZ_SCROLLDATA; i++)
29099 859754 FFCore.ScrollingData[i] = cached_scrolling[i];
29100 27734 }
29101
29102 // cur_dmap won't change until the end of the scroll. Store new dmap in this global variable.
29103 27954 scrolling_destdmap = new_dmap;
29104
29105 // Calling functions are responsible for setting cur_map (but not cur_screen...), but before we
29106 // _actually_ start to scroll we draw a few frames of the current screen (draw_screen). So we
29107 // need cur_map to be the old value initially. Callers also set the old map value to
29108 // `scrolling_map`, so we can use that.
29109 27954 int destmap = cur_map;
29110 27954 cur_map = scrolling_map;
29111
29112 // This adjusts how drawing commands are interpreted in `do_drawing_command`.
29113 // Currently, since only one set of screen scripts/item scripts/etc. can run at a time during
29114 // scrolling (either the old screens, which was above and this next "waiting" phase, or the new
29115 // screens, which comes after this next part) - a boolean is enough to capture this. If this
29116 // changes, we need to vary this behavior based on "is this from the new or old set of screens?"
29117 27954 scrolling_using_new_region_coords = true;
29118
29119 // Wait at least one frame, possibly 32.
29120 // These frames will use the new region's coordinates.
29121 {
29122 27954 int wait_counter = scx + 1;
29123
2/2
✓ Branch 0 taken 139106 times.
✓ Branch 1 taken 27954 times.
167060 while (wait_counter < 32)
29124 {
29125
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if(isForceFaceUp) dir = up;
29126
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 138363 times.
139106 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29127 {
29128 743 script_drawing_commands.Clear();
29129 743 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29130 743 ZScriptVersion::RunScrollingScript(scrolldir, wait_counter, 0, 0, false, false); // Prewaitdraw
29131 743 ZScriptVersion::RunScrollingScript(scrolldir, wait_counter, 0, 0, false, true); // Waitdraw
29132 743 }
29133 138363 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29134 139106 draw_screen(true,true);
29135
29136
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if (wait_counter == scx)
29137 rehydratelake(false);
29138
29139 139106 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29140 139106 advanceframe(true);
29141
29142
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if(Quit)
29143 {
29144 screenscrolling = false;
29145 return;
29146 }
29147
29148 139106 ++wait_counter;
29149 }
29150 }
29151
29152 27954 script_drawing_commands.Clear();
29153 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29154
29155 // Just trying to play the sound.
29156
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 26924 times.
27954 if (original_destscr == -1)
29157 26924 checkmaze(origin_scr, true);
29158
29159
3/4
✓ Branch 0 taken 12413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6861 times.
✓ Branch 3 taken 8680 times.
27954 switch(DMaps[cur_dmap].type&dmfTYPE)
29160 {
29161 case dmDNGN:
29162
2/2
✓ Branch 0 taken 8673 times.
✓ Branch 1 taken 7 times.
8680 if(!get_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING))
29163 {
29164 7 markBmap(scrolldir, hero_screen);
29165 7 }
29166 8680 break;
29167 case dmOVERW: case dmBSOVERW:
29168
2/2
✓ Branch 0 taken 12016 times.
✓ Branch 1 taken 397 times.
12413 if(get_qr(qr_NO_OVERWORLD_MAP_CHARTING))
29169 12016 break;
29170 [[fallthrough]];
29171 case dmCAVE:
29172 7258 markBmap(scrolldir, hero_screen);
29173 7258 break;
29174 }
29175
29176 // Remember everything about the current region, because `loadscr` is about to reset this data.
29177 27954 std::vector<mapscr*> old_temporary_screens;
29178
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 old_temporary_screens = take_temporary_scrs();
29179
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 FFCore.ScrollingScreensAll = old_temporary_screens;
29180 27954 cur_map = destmap;
29181
29182
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 loadscr(destdmap, dest_screen, scrolldir, overlay);
29183 27954 mapscr* oldscr = old_temporary_screens[scrolling_hero_screen * 7];
29184
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 mapscr* newscr = get_scr(destmap, dest_screen);
29185
29186 // Start scrolling with the previous pfo, and adjust during scrolling if necessary.
29187 27954 int new_playing_field_offset = playing_field_offset;
29188 27954 playing_field_offset = old_original_playing_field_offset;
29189
29190 // We must recalculate the new hero position and viewport, if a script run above just change the
29191 // hero position.
29192
10/16
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27924 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 27924 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27924 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27924 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 163 times.
✓ Branch 15 taken 27761 times.
27954 if (hero_x_before_scripts != x || hero_y_before_scripts != y)
29193 {
29194
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 calc_new_viewport_and_pos();
29195
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 calc_scroll_data();
29196
29197 193 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_X] = new_viewport.x;
29198 193 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_Y] = new_viewport.y;
29199
29200 193 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_X] = viewport.x;
29201 193 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_Y] = viewport.y;
29202
29203
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
29204
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
29205 193 }
29206
29207 // 0 for change playing field offset, then scroll.
29208 // 1 for scroll, then change playing field offset.
29209 27954 int pfo_mode = 0;
29210
29211
2/2
✓ Branch 0 taken 5955 times.
✓ Branch 1 taken 21999 times.
27954 if (dy == 1)
29212 5955 pfo_mode = 0;
29213
2/2
✓ Branch 0 taken 8078 times.
✓ Branch 1 taken 13921 times.
21999 else if (dy == -1)
29214 8078 pfo_mode = 1;
29215
5/6
✓ Branch 0 taken 13875 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 13875 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13845 times.
✓ Branch 5 taken 30 times.
13921 else if (old_region_scr_dy == 0 && sign(new_playing_field_offset - old_original_playing_field_offset) == -1)
29216 30 pfo_mode = 1;
29217
29218 27954 int pfo_counter = abs(new_playing_field_offset - old_original_playing_field_offset);
29219
29220 // When scrolling up/down, and if scrolling first and the final pfo is less, reduce the scroll distance.
29221
6/6
✓ Branch 0 taken 14033 times.
✓ Branch 1 taken 13921 times.
✓ Branch 2 taken 8078 times.
✓ Branch 3 taken 5955 times.
✓ Branch 4 taken 8076 times.
✓ Branch 5 taken 2 times.
27954 if (dy && pfo_mode == 1 && new_playing_field_offset > old_original_playing_field_offset)
29222 {
29223 2 scroll_amount += new_playing_field_offset - old_original_playing_field_offset;
29224 2 scroll_counter = scroll_amount / step;
29225 2 }
29226
29227 // If adjusting pfo first and the final pfo is more, increase the scroll distance.
29228 // Also make the pfo adjust instantly.
29229
6/6
✓ Branch 0 taken 14033 times.
✓ Branch 1 taken 13921 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 8078 times.
✓ Branch 4 taken 5953 times.
✓ Branch 5 taken 2 times.
27954 if (dy && pfo_mode == 0 && new_playing_field_offset < old_original_playing_field_offset)
29230 {
29231 2 scroll_amount -= new_playing_field_offset - old_original_playing_field_offset;
29232 2 scroll_counter = scroll_amount / step;
29233 2 pfo_counter = 1;
29234 2 }
29235
29236 viewport_t old_world_rect;
29237 27954 old_world_rect.x = 0;
29238 27954 old_world_rect.y = 0;
29239 27954 old_world_rect.w = old_world_w;
29240 27954 old_world_rect.h = old_world_h;
29241
29242 viewport_t new_world_rect;
29243 27954 new_world_rect.x = 0;
29244 27954 new_world_rect.y = 0;
29245 27954 new_world_rect.w = world_w;
29246 27954 new_world_rect.h = world_h;
29247
29248 // 0 for align, then scroll.
29249 // 1 for scroll, then align.
29250 27954 int align_mode = 0;
29251 27954 int align_counter = abs(secondary_axis_alignment_amount);
29252 // Align first, unless that would show screens outside the old region.
29253
2/2
✓ Branch 0 taken 27876 times.
✓ Branch 1 taken 78 times.
27954 if (align_counter)
29254 {
29255 78 viewport_t old_viewport_aligned = old_viewport;
29256
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 10 times.
78 old_viewport_aligned.x -= (dy ? secondary_axis_alignment_amount : 0);
29257
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 68 times.
78 old_viewport_aligned.y -= (dx ? secondary_axis_alignment_amount : 0);
29258 // The playing field offset is changed before aligning, so apply the delta in this check.
29259
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 28 times.
78 if (pfo_mode == 0)
29260 50 old_viewport_aligned.y += new_playing_field_offset - old_original_playing_field_offset;
29261
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 44 times.
78 if (old_world_rect.contains_or_on(old_viewport_aligned))
29262 34 align_mode = 0;
29263 else
29264 44 align_mode = 1;
29265 78 }
29266
29267 // Determine the area that will be visible in the old and the new regions,
29268 // taking into account any possible alignment. All screens within these
29269 // area will be fetched by get_nearby_scrolling_screens.
29270
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 rect_t old_region_visible = rect_t(old_viewport);
29271
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 rect_t new_region_visible = rect_t(new_viewport);
29272
2/2
✓ Branch 0 taken 27876 times.
✓ Branch 1 taken 78 times.
27954 if (secondary_axis_alignment_amount)
29273 {
29274
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 34 times.
78 rect_t& r = align_mode == 0 ? old_region_visible : new_region_visible;
29275
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 34 times.
78 int delta = align_mode == 0 ? -secondary_axis_alignment_amount : secondary_axis_alignment_amount;
29276
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 68 times.
78 if (dy)
29277 {
29278
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (delta > 0)
29279 8 r.r += delta;
29280 else
29281 2 r.l += delta;
29282 10 }
29283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 else if (dx)
29284 {
29285
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 52 times.
68 if (delta > 0)
29286 16 r.b += delta;
29287 else
29288 52 r.t += delta;
29289 68 }
29290 78 }
29291
29292
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 old_region_visible.intersect_with(rect_t(old_world_rect));
29293
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 new_region_visible.intersect_with(rect_t(new_world_rect));
29294
29295 // For the duration of the scrolling, the old region coordinate system is used for all drawing
29296 // operations. This means that the new screens are drawn with offsets relative to the old
29297 // coordinate system. These offsets are determined in get_nearby_scrolling_screens.
29298
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 auto nearby_screens = get_nearby_scrolling_screens(old_temporary_screens, old_viewport, new_viewport, old_region_visible, new_region_visible);
29299
29300
2/2
✓ Branch 0 taken 6520 times.
✓ Branch 1 taken 21434 times.
27954 int sx = viewport.x + (scrolldir == left ? viewport.w : 0);
29301
2/2
✓ Branch 0 taken 19876 times.
✓ Branch 1 taken 8078 times.
27954 int sy = viewport.y + (scrolldir == up ? viewport.h : 0);
29302
2/2
✓ Branch 0 taken 27273 times.
✓ Branch 1 taken 681 times.
27954 if (is_unsmooth_vertical_scrolling) sy += 3;
29303
29304 // We must recalculate the new hero position, if a script run above just change the
29305 // hero position.
29306
8/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27924 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 27924 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27924 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27924 times.
✗ Branch 13 not taken.
27954 if (hero_x_before_scripts != x || hero_y_before_scripts != y)
29307 {
29308
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 27761 times.
27954 calc_new_viewport_and_pos();
29309
29310
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
29311
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
29312 193 }
29313
29314 // change Hero's state if entering water
29315
6/10
✓ Branch 0 taken 27954 times.
✓ Branch 1 taken 27761 times.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
193 int32_t ahead = lookahead(scrolldir, new_hero_x, new_hero_y + 8);
29316
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
27954 auto [lookaheadx, lookaheady] = lookahead_coords(scrolldir, new_hero_x + 8, new_hero_y + (bigHitbox?8:12));
29317
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
82704 auto [wateraheadx1, wateraheady1] = lookahead_coords(scrolldir, new_hero_x + 4, new_hero_y + 9);
29318
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
28714 auto [wateraheadx2, wateraheady2] = lookahead_coords(scrolldir, new_hero_x + 11, new_hero_y + 15);
29319
29320 27954 bool nowinwater = false;
29321 {
29322
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if(lastaction != inwind)
29323 {
29324
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27375 times.
27829 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
29325 {
29326
5/8
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 438 times.
✓ Branch 7 taken 16 times.
454 if (lookaheadraftflag(scrolldir, new_hero_x, new_hero_y))
29327 {
29328
1/2
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
438 action=rafting; FFCore.setHeroAction(rafting);
29329 438 raftclk=0;
29330 438 }
29331 454 }
29332
13/20
✓ Branch 0 taken 27375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27375 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27375 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✓ Branch 7 taken 26995 times.
✓ Branch 8 taken 380 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 380 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 380 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 373 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 373 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 348 times.
✓ Branch 19 taken 25 times.
82125 else if(iswaterex_z3(ahead, -1, wateraheadx1,wateraheady1) && iswaterex_z3(ahead, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
29333 {
29334
9/16
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
348 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
29335 {
29336
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 SetSwim();
29337 328 hopclk = 0xFF;
29338 328 nowinwater = true;
29339 328 }
29340 else
29341 {
29342
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 action=hopping; FFCore.setHeroAction(hopping);
29343 20 hopclk = 2;
29344 20 nowinwater = true;
29345 }
29346 348 }
29347
4/4
✓ Branch 0 taken 26979 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 26995 times.
27027 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
29348 {
29349
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 action = lastaction; FFCore.setHeroAction(lastaction);
29350 32 }
29351 else
29352 {
29353
1/2
✓ Branch 0 taken 26995 times.
✗ Branch 1 not taken.
26995 action=none; FFCore.setHeroAction(none);
29354 }
29355 27829 }
29356
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
29357 {
29358 action = lastaction; FFCore.setHeroAction(lastaction);
29359 }
29360 else
29361 {
29362
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 action=none; FFCore.setHeroAction(none);
29363 }
29364
29365
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27954 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
29366
29367 // The naturaldark state can be read/set by an FFC script before
29368 // fade() or lighting() is called.
29369
3/4
✓ Branch 0 taken 25737 times.
✓ Branch 1 taken 2217 times.
✓ Branch 2 taken 25737 times.
✗ Branch 3 not taken.
53691 naturaldark = !get_qr(qr_NEW_DARKROOM) && is_dark(newscr);
29370
29371
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 27652 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
27954 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
29372
29373
3/4
✓ Branch 0 taken 455 times.
✓ Branch 1 taken 27499 times.
✓ Branch 2 taken 455 times.
✗ Branch 3 not taken.
27954 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
29374
29375 //Preloaded ffc scripts
29376 {
29377 // Kludge
29378 27954 cur_dmap = new_dmap;
29379
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 ffscript_engine(true);
29380 27954 cur_dmap = old_dmap;
29381 }
29382
29383 // There are two occasions when scrolling must be darkened:
29384 // 1) When scrolling into a dark room.
29385 // 2) When scrolling between DMaps of different colours.
29386
4/4
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 26926 times.
✓ Branch 2 taken 489 times.
✓ Branch 3 taken 539 times.
27954 if(destdmap != -1 && DMaps[destdmap].color != currcset)
29387 {
29388
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 539 times.
✗ Branch 3 not taken.
539 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
29389 539 darkroom = true;
29390 539 }
29391
2/2
✓ Branch 0 taken 27161 times.
✓ Branch 1 taken 254 times.
27415 else if(!darkroom)
29392
1/2
✓ Branch 0 taken 27161 times.
✗ Branch 1 not taken.
27161 lighting(false, false); // NES behaviour: fade to dark before scrolling
29393
29394
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27500 times.
27954 if(action != rafting) // Is this supposed to be here?!
29395 27500 scroll_counter++; //This was the easiest way to re-arrange the loop so drawing is in the middle
29396 }
29397
29398 27954 bool draw_dark = false;
29399
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
84226 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29400 56272 mapscr* base_scr = screen_handles[0].scr;
29401
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 28136 times.
56272 bool dark = is_new_screen ? is_dark(base_scr) : scrolling_is_dark(base_scr);
29402 56272 draw_dark |= dark;
29403 56272 });
29404
29405 27954 int no_move = 0;
29406 27954 int move_counter = 0;
29407 27954 bool end_frames = false;
29408
29409 27954 scroll_counter *= delay;
29410
29411
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 if (get_qr(qr_NOSCROLL))
29412 {
29413 delay = 0;
29414 secondary_axis_alignment_amount = 0;
29415 pfo_counter = 0;
29416 align_counter = 0;
29417 }
29418
29419 27954 viewport_t initial_viewport = old_viewport;
29420 27954 viewport = initial_viewport;
29421
2/2
✓ Branch 0 taken 27273 times.
✓ Branch 1 taken 681 times.
27954 if (is_unsmooth_vertical_scrolling) viewport.y += 3;
29422
29423 // These mark the top-left coordinate of the new screen and the old screen, in the old region
29424 // coordinates.
29425 27954 int nx = 0;
29426 27954 int ny = 0;
29427 27954 int ox = 0;
29428 27954 int oy = 0;
29429
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
84226 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29430
4/4
✓ Branch 0 taken 28129 times.
✓ Branch 1 taken 28143 times.
✓ Branch 2 taken 175 times.
✓ Branch 3 taken 27954 times.
56272 if (screen == dest_screen && is_new_screen)
29431 {
29432 27954 nx = offx;
29433 27954 ny = offy;
29434 27954 }
29435
4/4
✓ Branch 0 taken 27960 times.
✓ Branch 1 taken 358 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 27954 times.
28318 else if (screen == scrolling_hero_screen && !is_new_screen)
29436 {
29437 27954 ox = offx;
29438 27954 oy = offy;
29439 27954 }
29440 56272 });
29441
29442 // FFCs coordinates are world positions, and so don't need an offset like when drawing a
29443 // specific screen's combos in do_scrolling_layer. But since their coordinates are in the new
29444 // region's coordinate system, an offset of the difference between the two coordinate systems is
29445 // needed.
29446 // TODO: figure out how to calculate this in calc_new_viewport_and_pos, before their first usage...
29447
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 new_region_offset_x = nx - get_region_relative_dx(dest_screen)*256;
29448
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 new_region_offset_y = ny - get_region_relative_dy(dest_screen)*176;
29449
29450 27954 cur_dmap = new_dmap;
29451
6/6
✓ Branch 0 taken 1631482 times.
✓ Branch 1 taken 28724 times.
✓ Branch 2 taken 572 times.
✓ Branch 3 taken 28152 times.
✓ Branch 4 taken 27950 times.
✓ Branch 5 taken 1632256 times.
1660206 for (int i = 0; (scroll_counter >= 0 && delay != 0) || align_counter || pfo_counter; i++, scroll_counter--)
29452 {
29453 // Scripts see the hero position as if relative to the scrolling viewport. This is a weird
29454 // quirk that should probably be placed behind a compat QR.
29455
2/4
✓ Branch 0 taken 1632256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632256 times.
✗ Branch 3 not taken.
1632256 zfix prev_x, prev_y;
29456 #define SAVE_HERO_POS {prev_x = x; prev_y = y;}
29457 #define USE_COMPAT_HERO_POS {x -= viewport.x; y -= viewport.y;}
29458 #define RESTORE_HERO_POS {x = prev_x; y = prev_y;}
29459
29460
3/4
✓ Branch 0 taken 1632256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159376 times.
✓ Branch 3 taken 1472880 times.
1632256 if (replay_version_check(0, 3))
29461 {
29462
1/2
✓ Branch 0 taken 159376 times.
✗ Branch 1 not taken.
159376 replay_poll();
29463 159376 }
29464
29465
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1632253 times.
1632256 if(Quit)
29466 {
29467 // Just for compat with pre-z3 replays that quit during a scroll.
29468
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (replay_is_recording())
29469 {
29470 USE_COMPAT_HERO_POS;
29471 }
29472 3 screenscrolling = false;
29473 3 return;
29474 }
29475
29476
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
29477
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
29478
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, false);
29479
3/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3909291 times.
✓ Branch 3 taken 2277038 times.
1632253 RESTORE_HERO_POS;
29480
29481
2/2
✓ Branch 0 taken 3791717 times.
✓ Branch 1 taken 117574 times.
3909291 if(no_move > 0)
29482 117574 no_move--;
29483
29484 //Don't want to move things on the first or last iteration, or between delays, or while aligning, or while adjusting playing field offset
29485
12/12
✓ Branch 0 taken 1604299 times.
✓ Branch 1 taken 2304992 times.
✓ Branch 2 taken 1563005 times.
✓ Branch 3 taken 41294 times.
✓ Branch 4 taken 1529956 times.
✓ Branch 5 taken 33049 times.
✓ Branch 6 taken 1526616 times.
✓ Branch 7 taken 3340 times.
✓ Branch 8 taken 1166473 times.
✓ Branch 9 taken 2693089 times.
✓ Branch 10 taken 1167337 times.
✓ Branch 11 taken 1529092 times.
3909291 if(i == 0 || scroll_counter == 0 || scroll_counter % delay != 0 || (align_mode == 0 && align_counter) || (pfo_mode == 0 && pfo_counter))
29486 4713145 no_move++;
29487
29488
4/4
✓ Branch 0 taken 1224588 times.
✓ Branch 1 taken 407665 times.
✓ Branch 2 taken 294554 times.
✓ Branch 3 taken 930034 times.
1632253 if(scrolldir == up || scrolldir == down)
29489 {
29490
2/2
✓ Branch 0 taken 652149 times.
✓ Branch 1 taken 50070 times.
702219 if(!get_qr(qr_SMOOTHVERTICALSCROLLING))
29491 {
29492 //Add a few extra frames if on the second loop and cool scrolling is not set
29493
2/2
✓ Branch 0 taken 49389 times.
✓ Branch 1 taken 681 times.
50070 if(i == 1)
29494 {
29495 681 scroll_counter += (scrolldir == down) ? 3 : 2;
29496 681 no_move += (scrolldir == down) ? 3 : 2;
29497 681 }
29498 50070 }
29499 else
29500 {
29501 //4 frames after we've finished scrolling of being still
29502
6/6
✓ Branch 0 taken 26696 times.
✓ Branch 1 taken 625453 times.
✓ Branch 2 taken 26688 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 13344 times.
✓ Branch 5 taken 13344 times.
652149 if (scroll_counter == 0 && pfo_counter == 0 && !end_frames)
29503 {
29504 13344 scroll_counter += 4;
29505 13344 no_move += 4;
29506 13344 end_frames = true;
29507 13344 }
29508 }
29509 702219 }
29510
29511
2/2
✓ Branch 0 taken 1628821 times.
✓ Branch 1 taken 3432 times.
1632253 if (align_mode == 0)
29512 {
29513
5/6
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 1628131 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 438 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 252 times.
1628821 if (align_counter > 0 && (pfo_counter == 0 || pfo_mode == 1))
29514 {
29515
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 420 times.
438 align_counter = MAX(0, align_counter - 4);
29516
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 34 times.
438 if (align_counter)
29517 404 scroll_counter++;
29518 438 }
29519 1628821 }
29520 else
29521 {
29522
5/6
✓ Branch 0 taken 3370 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2798 times.
✓ Branch 3 taken 572 times.
✓ Branch 4 taken 2798 times.
✗ Branch 5 not taken.
3432 if (align_counter > 0 && !(scroll_counter >= 0 && delay != 0))
29523 {
29524
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 560 times.
572 align_counter = MAX(0, align_counter - 4);
29525 572 no_move = 1;
29526 572 }
29527 }
29528
29529 1632253 bool do_pfo_adjust = false;
29530
2/2
✓ Branch 0 taken 1222180 times.
✓ Branch 1 taken 410073 times.
1632253 if (pfo_mode == 0)
29531 {
29532
2/2
✓ Branch 0 taken 1221702 times.
✓ Branch 1 taken 478 times.
1222180 if (pfo_counter > 0)
29533 478 do_pfo_adjust = true;
29534 1222180 }
29535 else
29536 {
29537
5/6
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 407165 times.
✓ Branch 2 taken 2376 times.
✓ Branch 3 taken 532 times.
✓ Branch 4 taken 2376 times.
✗ Branch 5 not taken.
410073 if (pfo_counter > 0 && !(scroll_counter >= 0 && delay != 0))
29538 {
29539 532 do_pfo_adjust = true;
29540 532 no_move = 1;
29541 532 }
29542 }
29543
29544
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 1631243 times.
1632253 if (do_pfo_adjust)
29545 {
29546
1/2
✓ Branch 0 taken 1010 times.
✗ Branch 1 not taken.
1010 int dpfo = sign(new_playing_field_offset - old_original_playing_field_offset);
29547
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1008 times.
1010 pfo_counter = MAX(0, pfo_counter - 4);
29548 1010 playing_field_offset = new_playing_field_offset - pfo_counter * dpfo;
29549 1010 viewport.h = 232 - playing_field_offset;
29550 1010 viewport.y = initial_viewport.y + step * move_counter * dy + (playing_field_offset - old_original_playing_field_offset);
29551
4/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 442 times.
1010 if (pfo_mode == 0 && pfo_counter)
29552 442 scroll_counter++;
29553 1010 }
29554
29555
2/2
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 1631460 times.
1632253 if (lift_wpn)
29556
1/2
✓ Branch 0 taken 793 times.
✗ Branch 1 not taken.
793 lift_wpn->yofs = playing_field_offset - 2;
29557
29558
2/2
✓ Branch 0 taken 1486729 times.
✓ Branch 1 taken 145524 times.
1632253 if(!no_move)
29559 {
29560
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 335769 times.
✓ Branch 2 taken 250170 times.
✓ Branch 3 taken 420541 times.
✓ Branch 4 taken 480249 times.
1486729 switch(scrolldir)
29561 {
29562 case up:
29563 335769 sy -= step;
29564 335769 break;
29565
29566 case down:
29567 250170 sy += step;
29568 250170 break;
29569
29570 case left:
29571 420541 sx -= step;
29572 420541 break;
29573
29574 case right:
29575 480249 sx += step;
29576 480249 break;
29577 }
29578
29579 1486729 move_counter++;
29580 {
29581 1486729 viewport.x = initial_viewport.x + step * move_counter * dx;
29582 1486729 viewport.y = initial_viewport.y + step * move_counter * dy + playing_field_offset - old_original_playing_field_offset;
29583 }
29584
29585 // This is the only thing that moves the hero.
29586
2/4
✓ Branch 0 taken 1486729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1486729 times.
✗ Branch 3 not taken.
1486729 if (!sideview_scrolling_slope)
29587 {
29588
4/4
✓ Branch 0 taken 1066188 times.
✓ Branch 1 taken 420541 times.
✓ Branch 2 taken 585939 times.
✓ Branch 3 taken 480249 times.
1486729 if (scrolling_dir == left || scrolling_dir == right)
29589 {
29590
2/4
✓ Branch 0 taken 900790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 900790 times.
✗ Branch 3 not taken.
900790 x.doClamp(viewport.x, viewport.right() - 16);
29591 900790 }
29592 else
29593 {
29594
2/4
✓ Branch 0 taken 585939 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 585939 times.
✗ Branch 3 not taken.
585939 y.doClamp(viewport.y, viewport.bottom() - 16);
29595 }
29596 1486729 }
29597
29598
2/2
✓ Branch 0 taken 1472627 times.
✓ Branch 1 taken 14102 times.
1486729 if (is_unsmooth_vertical_scrolling) viewport.y += 3;
29599
29600
4/4
✓ Branch 0 taken 1486601 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1486473 times.
1486729 if(ladderx > 0 || laddery > 0)
29601 {
29602 // If the ladder moves on both axes, the player can
29603 // gradually shift it by going back and forth
29604
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(scrolldir==up || scrolldir==down)
29605 laddery = y.getInt();
29606 else
29607
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 ladderx = x.getInt();
29608 256 }
29609 1486729 }
29610
29611
2/2
✓ Branch 0 taken 6314 times.
✓ Branch 1 taken 1625939 times.
1632253 if (secondary_axis_alignment_amount)
29612 {
29613
1/2
✓ Branch 0 taken 6314 times.
✗ Branch 1 not taken.
6314 int delta = (align_counter - abs(secondary_axis_alignment_amount)) * sign(secondary_axis_alignment_amount);
29614
4/4
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 284 times.
✓ Branch 3 taken 5660 times.
6314 if (scrolldir == up || scrolldir == down) viewport.x = initial_viewport.x + delta;
29615 5660 else viewport.y = initial_viewport.y + delta + (playing_field_offset - old_original_playing_field_offset);
29616 6314 }
29617
29618 1632253 FFCore.ScrollingData[SCROLLDATA_NX] = nx - viewport.x;
29619 1632253 FFCore.ScrollingData[SCROLLDATA_NY] = ny - viewport.y;
29620 1632253 FFCore.ScrollingData[SCROLLDATA_OX] = ox - viewport.x;
29621 1632253 FFCore.ScrollingData[SCROLLDATA_OY] = oy - viewport.y;
29622 1632253 FFCore.ScrollingData[SCROLLDATA_NRX] = new_region_offset_x - viewport.x;
29623 1632253 FFCore.ScrollingData[SCROLLDATA_NRY] = new_region_offset_y - viewport.y;
29624 1632253 FFCore.ScrollingData[SCROLLDATA_ORX] = -viewport.x;
29625 1632253 FFCore.ScrollingData[SCROLLDATA_ORY] = -viewport.y;
29626
29627
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
29628
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
29629
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, true); //Waitdraw
29630
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
29631
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
29632
29633
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 clear_bitmap(framebuf);
29634
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 clear_info_bmp();
29635
29636
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29637 3290530 mapscr* base_scr = screen_handles[0].base_scr;
29638
2/2
✓ Branch 0 taken 3288922 times.
✓ Branch 1 taken 1608 times.
3290530 if(XOR(base_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)) do_layer(framebuf, 0, screen_handles[2], offx, offy);
29639 3290530 });
29640
4/4
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 1631406 times.
✓ Branch 2 taken 1608 times.
✓ Branch 3 taken 1630645 times.
1632253 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[cur_dmap].flags&dmfLAYER2BG))
29641
1/2
✓ Branch 0 taken 1608 times.
✗ Branch 1 not taken.
1608 do_primitives(framebuf, 2);
29642
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -2, nearby_screens, new_region_offset_x, new_region_offset_y);
29643
29644
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29645 3290530 mapscr* base_scr = screen_handles[0].base_scr;
29646
2/2
✓ Branch 0 taken 3280306 times.
✓ Branch 1 taken 10224 times.
3290530 if(XOR(base_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)) do_layer(framebuf, 0, screen_handles[3], offx, offy);
29647 3290530 });
29648
4/4
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 1627174 times.
✓ Branch 2 taken 6769 times.
✓ Branch 3 taken 1625484 times.
1632253 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[cur_dmap].flags&dmfLAYER3BG))
29649
1/2
✓ Branch 0 taken 6769 times.
✗ Branch 1 not taken.
6769 do_primitives(framebuf, 3);
29650
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -3, nearby_screens, new_region_offset_x, new_region_offset_y);
29651
29652 1632253 combotile_add_y = is_unsmooth_vertical_scrolling ? -3 : 0;
29653
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29654 3290530 offy += playing_field_offset;
29655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3290530 times.
3290530 if (lenscheck(screen_handles[0].scr, 0))
29656 3290530 putscr(screen_handles[0].scr, framebuf, offx, offy);
29657 3290530 });
29658 1632253 combotile_add_y = 0;
29659
29660
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 if (lenscheck(newscr, 0))
29661
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_primitives(framebuf, 0);
29662
29663
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 0, nearby_screens, new_region_offset_x, new_region_offset_y);
29664
29665
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29666 3290530 do_layer(framebuf, 0, screen_handles[1], offx, offy);
29667 3290530 });
29668
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 1);
29669
29670
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 1, nearby_screens, new_region_offset_x, new_region_offset_y);
29671
29672
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29673 3290530 mapscr* base_scr = screen_handles[0].base_scr;
29674
2/2
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 3288922 times.
3290530 if (!(XOR(base_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)))
29675 3288922 do_layer(framebuf, 0, screen_handles[2], offx, offy);
29676 3290530 });
29677
29678
4/4
✓ Branch 0 taken 1631492 times.
✓ Branch 1 taken 761 times.
✓ Branch 2 taken 1630645 times.
✓ Branch 3 taken 847 times.
1632253 if (!(oldscr->flags7&fLAYER2BG) && !(XOR(origin_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)))
29679
1/2
✓ Branch 0 taken 1630645 times.
✗ Branch 1 not taken.
1630645 do_layer_primitives(framebuf, 2);
29680
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 2, nearby_screens, new_region_offset_x, new_region_offset_y);
29681
29682
2/2
✓ Branch 0 taken 17236 times.
✓ Branch 1 taken 1615017 times.
1632253 if (get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
29683 {
29684
1/2
✓ Branch 0 taken 1615017 times.
✗ Branch 1 not taken.
4871075 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29685 3256058 do_layer(framebuf, -2, screen_handles[0], offx, offy);
29686
2/2
✓ Branch 0 taken 3127350 times.
✓ Branch 1 taken 128708 times.
3256058 if (get_qr(qr_PUSHBLOCK_LAYER_1_2))
29687 {
29688 128708 do_layer(framebuf, -2, screen_handles[1], offx, offy);
29689 128708 do_layer(framebuf, -2, screen_handles[2], offx, offy);
29690 128708 }
29691 3256058 });
29692
29693
1/2
✓ Branch 0 taken 1615017 times.
✗ Branch 1 not taken.
1615017 do_primitives(framebuf, SPLAYER_PUSHBLOCK);
29694 1615017 }
29695
29696
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1632253 times.
1632253 if (show_walkflags || show_effectflags)
29697 {
29698 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29699 do_walkflags(screen_handles, offx, offy); // show walkflags if the cheat is on
29700 do_effectflags(screen_handles[0].base_scr, offx, offy); // show effectflags if the cheat is on
29701 });
29702
29703 do_walkflags(nx, ny);
29704 }
29705
29706
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29707 3290530 offy += playing_field_offset;
29708 3290530 putscrdoors(screen_handles[0].scr, framebuf, offx, offy);
29709 3290530 });
29710
29711
4/4
✓ Branch 0 taken 3982 times.
✓ Branch 1 taken 1628271 times.
✓ Branch 2 taken 3938 times.
✓ Branch 3 taken 44 times.
1632253 if (!align_counter || scroll_counter) herostep();
29712
29713 {
29714
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 auto prev_y = y;
29715
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 auto prev_yofs = yofs;
29716
29717
3/4
✓ Branch 0 taken 50070 times.
✓ Branch 1 taken 1582183 times.
✓ Branch 2 taken 50070 times.
✗ Branch 3 not taken.
1632253 if (is_unsmooth_vertical_scrolling) y += 3;
29718
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 yofs = playing_field_offset;
29719
29720
7/12
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1631489 times.
✓ Branch 5 taken 764 times.
✓ Branch 6 taken 1631489 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1631489 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1632253 times.
1632253 if((z > 0 || fakez > 0) && (!get_qr(qr_SHADOWSFLICKER) || frame&1))
29721 {
29722
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1631489 times.
1632253 drawshadow(framebuf, get_qr(qr_TRANSSHADOWS) != 0);
29723 764 }
29724
29725
6/6
✓ Branch 0 taken 1632253 times.
✓ Branch 1 taken 1631489 times.
✓ Branch 2 taken 615767 times.
✓ Branch 3 taken 1016486 times.
✓ Branch 4 taken 295458 times.
✓ Branch 5 taken 320309 times.
764 if(!isdungeon() || get_qr(qr_FREEFORM))
29726 {
29727
3/4
✓ Branch 0 taken 1350340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38396 times.
✓ Branch 3 taken 1311944 times.
1350340 for (int i = 0; i < decorations.Count(); i++)
29728 {
29729
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 auto sprite = decorations.spr(i);
29730
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 sprite->yofs += playing_field_offset - old_original_playing_field_offset;
29731 38396 }
29732
29733
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 draw_under(framebuf); //draw the ladder or raft
29734
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 decorations.draw2(framebuf, true);
29735
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 draw(framebuf); //Hero
29736
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 decorations.draw(framebuf, true);
29737
29738
3/4
✓ Branch 0 taken 1350340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38396 times.
✓ Branch 3 taken 1311944 times.
1350340 for (int i = 0; i < decorations.Count(); i++)
29739 {
29740
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 auto sprite = decorations.spr(i);
29741
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 sprite->yofs -= playing_field_offset - old_original_playing_field_offset;
29742 38396 }
29743 1311944 }
29744
29745
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 y = prev_y;
29746
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 yofs = prev_yofs;
29747 }
29748
29749
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
29750
29751
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29752 3290530 mapscr* base_scr = screen_handles[0].base_scr;
29753
2/2
✓ Branch 0 taken 10224 times.
✓ Branch 1 taken 3280306 times.
3290530 if (!(XOR(base_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)))
29754 3280306 do_layer(framebuf, 0, screen_handles[3], offx, offy);
29755 3290530 });
29756
29757
2/2
✓ Branch 0 taken 1627174 times.
✓ Branch 1 taken 5079 times.
1632253 if (!(XOR(origin_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)))
29758
1/2
✓ Branch 0 taken 1627174 times.
✗ Branch 1 not taken.
1627174 do_layer_primitives(framebuf, 3);
29759
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 3, nearby_screens, new_region_offset_x, new_region_offset_y);
29760
29761
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29762 3290530 do_layer(framebuf, 0, screen_handles[4], offx, offy); //layer 4
29763 3290530 });
29764
29765
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 4);
29766
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 4, nearby_screens, new_region_offset_x, new_region_offset_y);
29767
29768
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29769 3290530 do_layer(framebuf, -1, screen_handles[0], offx, offy); //overhead combos
29770
2/2
✓ Branch 0 taken 3151618 times.
✓ Branch 1 taken 138912 times.
3290530 if (get_qr(qr_OVERHEAD_COMBOS_L1_L2))
29771 {
29772 138912 do_layer(framebuf, -1, screen_handles[1], offx, offy); //overhead combos
29773 138912 do_layer(framebuf, -1, screen_handles[2], offx, offy); //overhead combos
29774 138912 }
29775 3290530 });
29776
29777
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29778 3290530 do_layer(framebuf, 0, screen_handles[5], offx, offy); //layer 5
29779 3290530 });
29780
29781
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 5);
29782
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 5, nearby_screens, new_region_offset_x, new_region_offset_y);
29783
29784
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -1, nearby_screens, new_region_offset_x, new_region_offset_y);
29785
29786
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29787 3290530 do_layer(framebuf, 0, screen_handles[6], offx, offy); //layer 6
29788 3290530 });
29789
29790
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 6);
29791
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 6, nearby_screens, new_region_offset_x, new_region_offset_y);
29792
29793
6/6
✓ Branch 0 taken 88610 times.
✓ Branch 1 taken 1543643 times.
✓ Branch 2 taken 10406 times.
✓ Branch 3 taken 78204 times.
✓ Branch 4 taken 9814 times.
✓ Branch 5 taken 592 times.
1632253 if (draw_dark && get_qr(qr_NEW_DARKROOM) && get_qr(qr_NEWDARK_L6))
29794 {
29795
1/2
✓ Branch 0 taken 9814 times.
✗ Branch 1 not taken.
9814 scrollscr_handle_dark(newscr, oldscr, nearby_screens);
29796 9814 }
29797
29798
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 put_passive_subscr(framebuf, 0, 0, game->should_show_time(), sspUP);
29799
29800
2/2
✓ Branch 0 taken 599269 times.
✓ Branch 1 taken 1032984 times.
1632253 if(get_qr(qr_SUBSCREENOVERSPRITES))
29801
1/2
✓ Branch 0 taken 599269 times.
✗ Branch 1 not taken.
599269 do_primitives(framebuf, 7);
29802
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 7, nearby_screens, new_region_offset_x, new_region_offset_y);
29803
29804
6/6
✓ Branch 0 taken 88610 times.
✓ Branch 1 taken 1543643 times.
✓ Branch 2 taken 10406 times.
✓ Branch 3 taken 78204 times.
✓ Branch 4 taken 592 times.
✓ Branch 5 taken 9814 times.
1632253 if (draw_dark && get_qr(qr_NEW_DARKROOM) && !get_qr(qr_NEWDARK_L6))
29805 {
29806
1/2
✓ Branch 0 taken 592 times.
✗ Branch 1 not taken.
592 scrollscr_handle_dark(newscr, oldscr, nearby_screens);
29807 592 }
29808
29809
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
29810
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
29811
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
29812
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29813
29814
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
29815
2/2
✓ Branch 0 taken 1632252 times.
✓ Branch 1 taken 1 times.
1632253 advanceframe(true/*,true,false*/);
29816
2/4
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632252 times.
✗ Branch 3 not taken.
1632252 USE_COMPAT_HERO_POS;
29817
29818 //Don't clear the last frame, unless 'fixed'
29819
2/2
✓ Branch 0 taken 28724 times.
✓ Branch 1 taken 1603528 times.
1632252 if (scroll_counter > 0 || get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29820
2/2
✓ Branch 0 taken 1606186 times.
✓ Branch 1 taken 26066 times.
1632252 script_drawing_commands.Clear();
29821
2/2
✓ Branch 0 taken 1632252 times.
✓ Branch 1 taken 26066 times.
1606186 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29822 1632252 actiontype lastaction = action;
29823
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 action=scrolling; FFCore.setHeroAction(scrolling);
29824
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 FFCore.runF6Engine();
29825
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 action=lastaction; FFCore.setHeroAction(lastaction);
29826
29827
2/4
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632252 times.
✗ Branch 3 not taken.
1632252 RESTORE_HERO_POS;
29828 1632252 }
29829 27950 cur_dmap = old_dmap;
29830
29831 // TODO(replays): Prior to z3 refactor, old scrolling code didn't clear the darkroom bitmaps at end of scroll,
29832 // so the first frame drawn had some lighting from previous screen...
29833 // game_loop clears these bitmaps but that should be moved to advanceframe, and these other calls to `clear_darkroom_bitmaps`
29834 // deleted.
29835
4/6
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 26520 times.
✓ Branch 2 taken 1430 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1430 times.
27950 if (draw_dark && !replay_is_active())
29836 clear_darkroom_bitmaps();
29837
29838
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_txt_display_buf);
29839
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_txt_display_buf, 1);
29840
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_bg_display_buf);
29841
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_bg_display_buf, 1);
29842
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_portrait_display_buf);
29843
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_portrait_display_buf, 1);
29844
29845 27950 viewport = new_viewport;
29846 27950 playing_field_offset = new_playing_field_offset;
29847
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 x = new_hero_x;
29848
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 y = new_hero_y;
29849
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 yofs = playing_field_offset;
29850
2/2
✓ Branch 0 taken 27948 times.
✓ Branch 1 taken 2 times.
27950 if(ladderx > 0 || laddery > 0)
29851 {
29852 // If the ladder moves on both axes, the player can
29853 // gradually shift it by going back and forth
29854
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 27946 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
27950 if(scrolldir==up || scrolldir==down)
29855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27946 times.
27946 laddery = y.getInt();
29856 else
29857
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ladderx = x.getInt();
29858 4 }
29859
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 35 times.
4 if (lift_wpn)
29860
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 lift_wpn->yofs = playing_field_offset - 2;
29861
29862
10/14
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 27880 times.
✓ Branch 2 taken 27950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27936 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 27936 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27936 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 27936 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14 times.
70 if((z > 0 || fakez > 0) && isSideViewHero())
29863 {
29864 y -= z;
29865 y -= fakez;
29866 z = 0;
29867 fakez = 0;
29868 }
29869
29870
2/2
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 27936 times.
14 set_respawn_point(false);
29871
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 trySideviewLadder();
29872 27950 warpx = -1;
29873 27950 warpy = -1;
29874
29875 27950 screenscrolling = false;
29876 27950 scrolling_using_new_region_coords = false;
29877 27950 scrolling_destdmap = -1;
29878 27950 memset(FFCore.ScrollingData, 0, sizeof(int32_t) * SZ_SCROLLDATA);
29879 27950 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
29880
29881
2/2
✓ Branch 0 taken 26922 times.
✓ Branch 1 taken 1028 times.
27950 if (destdmap != -1)
29882 {
29883 1028 bool changedlevel = false;
29884 1028 bool changeddmap = false;
29885
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 171 times.
1028 if (cur_dmap != destdmap)
29886 {
29887
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
29888 857 changeddmap = true;
29889 857 }
29890
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 846 times.
1028 if (DMaps[cur_dmap].level != DMaps[destdmap].level)
29891 {
29892
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
29893 182 changedlevel = true;
29894 182 }
29895 1028 dlevel = DMaps[destdmap].level;
29896 1028 cur_dmap = destdmap;
29897
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 171 times.
1028 if (changeddmap)
29898 {
29899
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
29900 857 }
29901
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 846 times.
1028 if (changedlevel)
29902 {
29903
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
29904 182 }
29905 1028 }
29906
29907 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
29908 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
29909 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
29910 //direction. -DD
29911
29912
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 27602 times.
27950 if(nowinwater)
29913 {
29914
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 SetSwim();
29915 348 hopclk = 0xFF;
29916 348 }
29917
29918 // NES behaviour: Fade to light after scrolling
29919
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 lighting(false, false); // No, we don't need to set naturaldark...
29920
29921
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 init_dmap();
29922
29923 // Check for raft flags
29924
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 26777 times.
✓ Branch 2 taken 25940 times.
✓ Branch 3 taken 57 times.
53947 if((get_qr(qr_BROKEN_RAFT_SCROLL) || lastaction == rafting)
29925
4/4
✓ Branch 0 taken 26323 times.
✓ Branch 1 taken 1627 times.
✓ Branch 2 taken 25997 times.
✓ Branch 3 taken 326 times.
27950 && action!=rafting && hopclk==0 && !toogam)
29926 {
29927
9/16
✓ Branch 0 taken 25940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25940 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25940 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25935 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 25935 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 25935 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 25935 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25935 times.
✗ Branch 15 not taken.
25940 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
29928 {
29929
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 sfx(hero_scr->secretsfx);
29930
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 action=rafting; FFCore.setHeroAction(rafting);
29931 5 raftclk=0;
29932 5 }
29933
29934 // Half a tile off?
29935
16/28
✓ Branch 0 taken 19656 times.
✓ Branch 1 taken 6279 times.
✓ Branch 2 taken 7071 times.
✓ Branch 3 taken 12585 times.
✓ Branch 4 taken 13350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13350 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13350 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13350 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13350 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13350 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13350 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 13350 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 13350 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13350 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 13350 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 25935 times.
39285 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
29936 {
29937 sfx(hero_scr->secretsfx);
29938 action=rafting; FFCore.setHeroAction(rafting);
29939 raftclk=0;
29940 }
29941 25940 }
29942
29943
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
56676 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
29944 28726 get_screen_state(scr->screen).open_doors = 0;
29945 28726 });
29946
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 markBmap();
29947
29948
3/4
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 19246 times.
27950 if (isdungeon(hero_screen))
29949 {
29950
4/4
✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 1694 times.
✓ Branch 2 taken 1904 times.
✓ Branch 3 taken 6 times.
8704 switch(hero_scr->door[scrolldir^1])
29951 {
29952 case dNONE:
29953 6 dir = scrolldir;
29954 6 break;
29955 case dOPEN:
29956 case dUNLOCKED:
29957 case dOPENBOSS:
29958 5100 dir = scrolldir;
29959
29960
1/2
✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
5100 if(action!=rafting)
29961
1/2
✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
5100 stepforward(diagonalMovement?11:12, false);
29962
29963 5100 break;
29964
29965 case dSHUTTER:
29966 case d1WAYSHUTTER:
29967 1694 dir = scrolldir;
29968
29969
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if(action!=rafting)
29970
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 stepforward(diagonalMovement?21:24, false);
29971
29972
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 putdoor(hero_scr, scrollbuf, scrolldir^1, hero_scr->door[scrolldir^1]);
29973
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 get_screen_state(hero_scr->screen).open_doors = -4;
29974
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 sfx(WAV_DOOR);
29975 1694 break;
29976
29977 default:
29978 1904 dir = scrolldir;
29979
29980
2/2
✓ Branch 0 taken 1857 times.
✓ Branch 1 taken 47 times.
1904 if(action!=rafting)
29981
1/2
✓ Branch 0 taken 1857 times.
✗ Branch 1 not taken.
1857 stepforward(diagonalMovement?21:24, false);
29982 1904 }
29983 8704 }
29984
29985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27950 times.
27950 if(action == scrolling)
29986 {
29987 action=none; FFCore.setHeroAction(none);
29988 }
29989
29990
3/4
✓ Branch 0 taken 27918 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27918 times.
27950 if(action != attacking && action != sideswimattacking)
29991 {
29992 27918 charging = 0;
29993 27918 tapping = false;
29994 27918 }
29995
29996
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 map_bkgsfx(true);
29997
29998
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 27916 times.
27950 if(newscr->flags2&fSECRET_SFX)
29999 {
30000
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 sfx(newscr->secretsfx);
30001 34 }
30002
30003
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 if (updatemusic)
30004 {
30005
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 playLevelMusic();
30006
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 if (musicrevert)
30007 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
30008 27950 }
30009
30010 // It happens that all decorations that are not drawn with an offset
30011 // are temporary sprites (like combo sprites) that should never carry over.
30012
3/4
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27950 times.
✓ Branch 3 taken 702 times.
28652 for (int i = decorations.Count()-1; i >=0; i--)
30013 {
30014
1/2
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
702 auto sprite = (decoration*)decorations.spr(i);
30015
3/4
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 695 times.
702 if (!sprite->is_drawn_with_offset())
30016
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 decorations.remove(sprite); // TODO: improve deletions by adding remove_by_index
30017
4/4
✓ Branch 0 taken 681 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 677 times.
695 else if (old_region.region_id || new_region.region_id)
30018
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 sprite->yofs = playing_field_offset;
30019 702 }
30020
30021 27950 newscr_clk = frame;
30022 27950 activated_timed_warp=false;
30023 27950 loadside = scrolldir^1;
30024
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 FFCore.clear_combo_scripts();
30025
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 eventlog_mapflags();
30026
2/2
✓ Branch 0 taken 5731419 times.
✓ Branch 1 taken 5759369 times.
27950 decorations.animate(); //continue to animate tall grass during scrolling
30027
2/2
✓ Branch 0 taken 1884 times.
✓ Branch 1 taken 5729535 times.
5731419 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
30028 {
30029
5/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1838 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 40 times.
1884 if (old_dmap == new_dmap || (replay_version_check(0, 15)))
30030 {
30031
1/2
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
1844 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, false); //Prewaitdraw
30032 1844 }
30033 1884 }
30034
30035 // Bye!
30036
2/2
✓ Branch 0 taken 26608400 times.
✓ Branch 1 taken 5731419 times.
32339819 for (int i = 0; i < 136*7; i++)
30037 {
30038
2/2
✓ Branch 0 taken 26407346 times.
✓ Branch 1 taken 201054 times.
26608400 if (old_temporary_screens[i])
30039 {
30040 201054 free(old_temporary_screens[i]);
30041 201054 old_temporary_screens[i] = NULL;
30042 201054 }
30043 26608400 }
30044 5731419 FFCore.ScrollingScreensAll.clear();
30045
30046
2/2
✓ Branch 0 taken 5729963 times.
✓ Branch 1 taken 1456 times.
5731419 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
30047 1456 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
30048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5731422 times.
17250160 }
30049
30050 // How much to reduce Hero's damage, taking into account various rings.
30051 15269 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
30052 {
30053
1/2
✓ Branch 0 taken 15269 times.
✗ Branch 1 not taken.
15269 if(dmg < 0) return dmg; //Don't reduce healing
30054
2/2
✓ Branch 0 taken 14539 times.
✓ Branch 1 taken 730 times.
15269 if ( get_qr(qr_BROKEN_RING_POWER) )
30055 {
30056 14539 int32_t divisor = 1;
30057 14539 float percentage = 1;
30058 14539 int32_t itemid = current_item_id(itype_ring);
30059 14539 bool usering = false;
30060
30061
4/4
✓ Branch 0 taken 10813 times.
✓ Branch 1 taken 3726 times.
✓ Branch 2 taken 324 times.
✓ Branch 3 taken 10489 times.
14539 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
30062 {
30063 10489 usering = true;
30064 10489 paymagiccost(itemid);
30065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10489 times.
10489 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30066 {
30067 percentage *= itemsbuf[itemid].power/100.0;
30068 }
30069 else
30070 {
30071 10489 divisor *= itemsbuf[itemid].power;
30072 }
30073 10489 }
30074
30075 /* Now for the Peril Ring */
30076 14539 itemid = current_item_id(itype_perilring);
30077
30078
8/10
✓ Branch 0 taken 2844 times.
✓ Branch 1 taken 11695 times.
✓ Branch 2 taken 2698 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 402 times.
✓ Branch 5 taken 2296 times.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 402 times.
14539 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
30079 {
30080 402 usering = true;
30081 402 paymagiccost(itemid);
30082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30083 {
30084 percentage *= itemsbuf[itemid].power/100.0;
30085 }
30086 else
30087 {
30088 402 divisor *= itemsbuf[itemid].power;
30089 }
30090 402 }
30091
30092 // Ring divisor of 0 = no damage. -L
30093
4/6
✓ Branch 0 taken 10507 times.
✓ Branch 1 taken 4032 times.
✓ Branch 2 taken 10507 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10507 times.
14539 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
30094 return 0;
30095
30096
1/2
✓ Branch 0 taken 14539 times.
✗ Branch 1 not taken.
14539 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
30097
30098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14539 times.
14539 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
30099
1/2
✓ Branch 0 taken 14539 times.
✗ Branch 1 not taken.
14539 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
30100
30101 }
30102 else
30103 {
30104 730 double divisor = 1;
30105 730 double percentage = 1;
30106 730 int32_t itemid = current_item_id(itype_ring);
30107 730 bool usering = false;
30108
30109
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 727 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
730 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
30110 {
30111 3 usering = true;
30112 3 paymagiccost(itemid);
30113
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30114 {
30115 1 double perc = itemsbuf[itemid].power/100.0;
30116
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
30117 1 percentage *= perc;
30118 1 }
30119 else
30120 {
30121
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
30122 divisor /= -(itemsbuf[itemid].power);
30123 2 else divisor *= itemsbuf[itemid].power;
30124 }
30125 3 }
30126
30127 /* Now for the Peril Ring */
30128 730 itemid = current_item_id(itype_perilring);
30129
30130
4/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
730 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
30131 {
30132 usering = true;
30133 paymagiccost(itemid);
30134 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30135 {
30136 double perc = itemsbuf[itemid].power/100.0;
30137 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
30138 percentage *= perc;
30139 }
30140 else
30141 {
30142 if(itemsbuf[itemid].power < 0)
30143 divisor /= -(itemsbuf[itemid].power);
30144 else divisor *= itemsbuf[itemid].power;
30145 }
30146 }
30147
30148 // Ring divisor of 0 = no damage. -L
30149
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
730 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
30150 return 0;
30151
30152 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
30153
1/2
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
730 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
30154 }
30155 15269 }
30156
30157 // Should swinging the hammer make the 'pound' sound?
30158 // Or is Hero just hitting air?
30159 6476 bool HeroClass::sideviewhammerpound()
30160 {
30161 6476 int32_t wx=0,wy=0;
30162
30163
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
✓ Branch 2 taken 1520 times.
✓ Branch 3 taken 2137 times.
✓ Branch 4 taken 1797 times.
6476 switch(dir)
30164 {
30165 case up:
30166 1022 wx=-1;
30167 1022 wy=-15;
30168
30169
1/2
✓ Branch 0 taken 1022 times.
✗ Branch 1 not taken.
1022 if(isSideViewHero()) wy+=8;
30170
30171 1022 break;
30172
30173 case down:
30174 1520 wx=8;
30175 1520 wy=28;
30176
30177
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 if(isSideViewHero()) wy-=8;
30178
30179 1520 break;
30180
30181 case left:
30182 2137 wx=-8;
30183 2137 wy=14;
30184
30185
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 12 times.
2137 if(isSideViewHero()) wy+=8;
30186
30187 2137 break;
30188
30189 case right:
30190 1797 wx=21;
30191 1797 wy=14;
30192
30193
1/2
✓ Branch 0 taken 1797 times.
✗ Branch 1 not taken.
1797 if(isSideViewHero()) wy+=8;
30194
30195 1797 break;
30196 }
30197
30198
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6464 times.
6476 if(!isSideViewHero())
30199 {
30200
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6455 times.
6464 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex_z3(MAPCOMBO(x+wx,y+wy), -1, x+wx,y+wy));
30201 }
30202
30203
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if(_walkflag(x+wx,y+wy,0,STANDING_Z_STATE)) return true;
30204
30205 if(dir==left || dir==right)
30206 {
30207 wx+=16;
30208
30209 if(_walkflag(x+wx,y+wy,0,STANDING_Z_STATE)) return true;
30210 }
30211
30212 return false;
30213 6476 }
30214
30215 // The following are only used for Hero damage. Damage is in quarter hearts.
30216 9215 int32_t enemy_dp(int32_t index)
30217 {
30218 9215 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
30219 }
30220
30221 5448 int32_t ewpn_dp(int32_t index)
30222 {
30223 5448 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
30224 }
30225
30226 43 int32_t lwpn_dp(int32_t index)
30227 {
30228 43 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
30229 }
30230
30231 137880136 bool checkbunny(int32_t itemid)
30232 {
30233
3/4
✓ Branch 0 taken 137779536 times.
✓ Branch 1 taken 100600 times.
✓ Branch 2 taken 100600 times.
✗ Branch 3 not taken.
137880136 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&item_bunny_enabled);
30234 }
30235
30236 16912578 bool usesSwordJinx(int32_t itemid)
30237 {
30238 16912578 itemdata const& it = itemsbuf[itemid];
30239 16912578 bool ret = (it.family==itype_sword);
30240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16912578 times.
16912578 if(it.flags & item_flip_jinx) return !ret;
30241 16912578 return ret;
30242 16912578 }
30243 40627216 bool checkitem_jinx(int32_t itemid)
30244 {
30245 40627216 itemdata const& it = itemsbuf[itemid];
30246
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 40623066 times.
40627216 if(it.flags & item_jinx_immune) return true;
30247
2/2
✓ Branch 0 taken 31306877 times.
✓ Branch 1 taken 9316189 times.
40623066 if (it.family == itype_shield){
30248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306877 times.
31306877 if(HeroShieldClk() != 0) return false;
30249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306877 times.
31306877 if(it.flags & !item_flag9) //Active Shields should also check sword/item jinx flags
30250 {
30251 if (usesSwordJinx(itemid)) return HeroSwordClk() == 0;
30252 return HeroItemClk() == 0;
30253 }
30254 31306877 return true;
30255
30256 }
30257
2/2
✓ Branch 0 taken 8460439 times.
✓ Branch 1 taken 855750 times.
9316189 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
30258 855750 return HeroItemClk() == 0;
30259 40627216 }
30260
30261 2 void stopCaneOfByrna()
30262 {
30263
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
30264 {
30265 40 weapon *w = ((weapon*)Lwpns.spr(i));
30266
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
30267 2 w->dead=1;
30268 40 }
30269 2 }
30270
30271 /* Crashes if used by ffscript.cpp, in case LINKITEMD
30272 void stopCaneOfByrna()
30273 {
30274 byte prnt_cane = -1;
30275 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
30276 prnt_cane = ew->parentitem;
30277 for(int32_t i=0; i<Lwpns.Count(); i++)
30278 {
30279 weapon *w = ((weapon*)Lwpns.spr(i));
30280
30281 if(w->id==wCByrna)
30282 {
30283 w->dead=1;
30284 }
30285 }
30286 if ( prnt_cane > -1 )
30287 {
30288 stop_sfx(itemsbuf[prnt_cane].usesound);
30289 }
30290 }
30291 */
30292 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
30293 14306884 void HeroClass::cleanupByrna()
30294 {
30295
2/2
✓ Branch 0 taken 14306807 times.
✓ Branch 1 taken 77 times.
14306884 if ( last_cane_of_byrna_item_id > -1 )
30296 {
30297
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
30298 {
30299 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
30300 2 last_cane_of_byrna_item_id = -1;
30301 2 }
30302 77 }
30303 14306884 }
30304
30305 // Used to find out if an item family is attached to one of the buttons currently pressed.
30306 4508163 bool isWpnPressed(int32_t itype)
30307 {
30308
4/4
✓ Branch 0 taken 529630 times.
✓ Branch 1 taken 3978533 times.
✓ Branch 2 taken 464621 times.
✓ Branch 3 taken 65009 times.
4508163 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return true;
30309
4/4
✓ Branch 0 taken 1593785 times.
✓ Branch 1 taken 2849369 times.
✓ Branch 2 taken 655017 times.
✓ Branch 3 taken 938768 times.
4443154 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return true;
30310
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 3502956 times.
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 864 times.
3504386 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return true;
30311
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 3503460 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 27 times.
3503522 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return true;
30312 3503487 return false;
30313 4508163 }
30314
30315 13733764 int32_t getWpnPressed(int32_t itype)
30316 {
30317
4/4
✓ Branch 0 taken 403543 times.
✓ Branch 1 taken 13330221 times.
✓ Branch 2 taken 394816 times.
✓ Branch 3 taken 8727 times.
13733764 if((itype==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn()) return Bwpn&0xFFF;
30318
3/4
✓ Branch 0 taken 28064 times.
✓ Branch 1 taken 13696973 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28064 times.
13725037 if((itype==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn()) return Awpn&0xFFF;
30319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13696973 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13696973 if((itype==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn()) return Xwpn&0xFFF;
30320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13696973 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13696973 if((itype==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn()) return Ywpn&0xFFF;
30321
30322 13696973 return -1;
30323 13733764 }
30324
30325 14309406 int32_t getRocsPressed()
30326 {
30327 14309406 int32_t jumpid = current_item_id(itype_rocs,true,true);
30328
30329
2/2
✓ Branch 0 taken 399372 times.
✓ Branch 1 taken 13910034 times.
14309406 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
30330
30331
2/2
✓ Branch 0 taken 13910034 times.
✓ Branch 1 taken 399372 times.
14309406 if (jumpid != -1)
30332 {
30333 399372 itemdata const& itm = itemsbuf[jumpid];
30334
30335 399372 byte intbtn = byte(itm.misc2&0xFF);
30336
1/2
✓ Branch 0 taken 399372 times.
✗ Branch 1 not taken.
399372 if(getIntBtnInput(intbtn, false, true, false, false, true))
30337 return jumpid; //not pressed
30338 399372 }
30339
30340
4/4
✓ Branch 0 taken 121155 times.
✓ Branch 1 taken 14188251 times.
✓ Branch 2 taken 115578 times.
✓ Branch 3 taken 5577 times.
14309406 if((itype_rocs==getItemFamily(itemsbuf,Bwpn)) && DrunkcBbtn())
30341 5577 return Bwpn;
30342
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303829 if((itype_rocs==getItemFamily(itemsbuf,Awpn)) && DrunkcAbtn())
30343 return Awpn;
30344
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303829 if((itype_rocs==getItemFamily(itemsbuf,Xwpn)) && DrunkcEx1btn())
30345 return Xwpn;
30346
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303829 if((itype_rocs==getItemFamily(itemsbuf,Ywpn)) && DrunkcEx2btn())
30347 return Ywpn;
30348
30349 14303829 return -1;
30350 14309406 }
30351
30352 bool isItmPressed(int32_t itmid)
30353 {
30354 if(itmid==(NEG_OR_MASK(Bwpn,0xFFF)) && DrunkcBbtn()) return true;
30355 if(itmid==(NEG_OR_MASK(Awpn,0xFFF)) && DrunkcAbtn()) return true;
30356 if(itmid==(NEG_OR_MASK(Xwpn,0xFFF)) && DrunkcEx1btn()) return true;
30357 if(itmid==(NEG_OR_MASK(Ywpn,0xFFF)) && DrunkcEx2btn()) return true;
30358 return false;
30359 }
30360
30361 //helper function
30362 23884 static void selectNextBTNWpn(int32_t type, word& wpos, int32_t& BTNwpn,
30363 int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
30364 {
30365
1/2
✓ Branch 0 taken 23884 times.
✗ Branch 1 not taken.
23884 if(!new_subscreen_active)
30366 return;
30367 23884 byte pgn = wpos&0xFF, pos = wpos>>8;
30368 23884 bool empty = pgn==255;
30369
3/4
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
✓ Branch 2 taken 9898 times.
✗ Branch 3 not taken.
23884 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
30370
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
23884 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
30371
1/2
✓ Branch 0 taken 23884 times.
✗ Branch 1 not taken.
23884 if(!pg)
30372 return;
30373
4/6
✓ Branch 0 taken 22497 times.
✓ Branch 1 taken 1387 times.
✓ Branch 2 taken 1387 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1387 times.
23884 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
30374
4/6
✓ Branch 0 taken 23880 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23884 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
30375
4/6
✓ Branch 0 taken 23880 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23884 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
30376 23884 auto ret = pg->movepos_legacy(type, wpos, fp1, fp2, fp3);
30377
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
23884 if((ret&0xFF) == 0xFF)
30378 9898 BTNwpn = -1;
30379 13986 else BTNwpn = pg->get_item_pos(ret>>8);
30380
2/2
✓ Branch 0 taken 13986 times.
✓ Branch 1 taken 9898 times.
23884 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
30381 23884 wpos = ret;
30382 23884 }
30383 5661 void selectNextAWpn(int32_t type)
30384 {
30385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5661 times.
5661 if(!get_qr(qr_SELECTAWPN))
30386 return;
30387
2/4
✓ Branch 0 taken 5661 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5661 times.
5661 selectNextBTNWpn(type, game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
30388 5661 }
30389
30390 18223 void selectNextBWpn(int32_t type)
30391 {
30392
1/2
✓ Branch 0 taken 18223 times.
✗ Branch 1 not taken.
18223 if(!new_subscreen_active)
30393 return;
30394
6/6
✓ Branch 0 taken 12897 times.
✓ Branch 1 taken 5326 times.
✓ Branch 2 taken 18219 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 18219 times.
18223 selectNextBTNWpn(type, game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
30395 18223 }
30396
30397 void selectNextXWpn(int32_t type)
30398 {
30399 if(!get_qr(qr_SET_XBUTTON_ITEMS)) return;
30400 if(!new_subscreen_active)
30401 return;
30402 selectNextBTNWpn(type, game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
30403 }
30404
30405 void selectNextYWpn(int32_t type)
30406 {
30407 if(!get_qr(qr_SET_YBUTTON_ITEMS)) return;
30408 if(!new_subscreen_active)
30409 return;
30410 selectNextBTNWpn(type, game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
30411 }
30412
30413 //helper function
30414 32087265 static void verifyWpn(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
30415 {
30416
2/2
✓ Branch 0 taken 32079396 times.
✓ Branch 1 taken 7869 times.
32087265 if(!new_subscreen_active)
30417 7869 return;
30418 32079396 byte pgn = wpos&0xFF, pos = wpos>>8;
30419 32079396 bool empty = pgn==255;
30420
4/4
✓ Branch 0 taken 2576275 times.
✓ Branch 1 taken 29503121 times.
✓ Branch 2 taken 1030357 times.
✓ Branch 3 taken 1545918 times.
32079396 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
30421
2/2
✓ Branch 0 taken 1030357 times.
✓ Branch 1 taken 29503121 times.
30533478 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
30422
1/2
✓ Branch 0 taken 30533478 times.
✗ Branch 1 not taken.
30533478 if(!pg)
30423 return;
30424
5/6
✓ Branch 0 taken 22813122 times.
✓ Branch 1 taken 7720356 times.
✓ Branch 2 taken 7661409 times.
✓ Branch 3 taken 58947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7661409 times.
30533478 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
30425
5/6
✓ Branch 0 taken 24536341 times.
✓ Branch 1 taken 5997137 times.
✓ Branch 2 taken 5996529 times.
✓ Branch 3 taken 608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5996529 times.
30533478 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
30426
5/6
✓ Branch 0 taken 25340698 times.
✓ Branch 1 taken 5192780 times.
✓ Branch 2 taken 5192742 times.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5192742 times.
30533478 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
30427 30533478 wpos = pg->movepos_legacy(SEL_VERIFY_RIGHT, wpos, fp1, fp2, fp3);
30428
2/2
✓ Branch 0 taken 1030182 times.
✓ Branch 1 taken 29503296 times.
30533478 if((wpos&0xFF) == 0xFF)
30429 1030182 BTNwpn = -1;
30430 29503296 else BTNwpn = pg->get_item_pos(wpos>>8);
30431
2/2
✓ Branch 0 taken 29240411 times.
✓ Branch 1 taken 1293067 times.
30533478 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
30432 32087265 }
30433
30434 24273866 void verifyAWpn()
30435 {
30436
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 24272847 times.
24273866 if (game->forced_awpn != -1)
30437 1019 return;
30438
2/2
✓ Branch 0 taken 1482306 times.
✓ Branch 1 taken 22790541 times.
24272847 if(!get_qr(qr_SELECTAWPN))
30439 {
30440 22790541 Awpn = selectSword();
30441 22790541 game->awpn = 255;
30442 22790541 }
30443 else
30444 {
30445
4/4
✓ Branch 0 taken 932154 times.
✓ Branch 1 taken 550152 times.
✓ Branch 2 taken 550152 times.
✓ Branch 3 taken 932154 times.
1482306 verifyWpn(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
30446 }
30447 24273866 }
30448
30449 24267488 void verifyBWpn()
30450 {
30451
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266475 times.
24267488 if (game->forced_bwpn != -1)
30452 1013 return;
30453
6/6
✓ Branch 0 taken 1481468 times.
✓ Branch 1 taken 22785007 times.
✓ Branch 2 taken 3169242 times.
✓ Branch 3 taken 21097233 times.
✓ Branch 4 taken 3169242 times.
✓ Branch 5 taken 21097233 times.
24266475 verifyWpn(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
30454 24267488 }
30455
30456 24267488 void verifyXWpn()
30457 {
30458
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266475 times.
24267488 if (game->forced_xwpn != -1)
30459 1013 return;
30460
2/2
✓ Branch 0 taken 3169242 times.
✓ Branch 1 taken 21097233 times.
24266475 if(!get_qr(qr_SET_XBUTTON_ITEMS))
30461 21097233 return;
30462
3/4
✓ Branch 0 taken 2619783 times.
✓ Branch 1 taken 549459 times.
✓ Branch 2 taken 3169242 times.
✗ Branch 3 not taken.
3169242 verifyWpn(game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
30463 24267488 }
30464
30465 24267488 void verifyYWpn()
30466 {
30467
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266475 times.
24267488 if (game->forced_ywpn != -1)
30468 1013 return;
30469
2/2
✓ Branch 0 taken 3169242 times.
✓ Branch 1 taken 21097233 times.
24266475 if(!get_qr(qr_SET_YBUTTON_ITEMS))
30470 21097233 return;
30471
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3169242 times.
✓ Branch 2 taken 549459 times.
✓ Branch 3 taken 2619783 times.
3169242 verifyWpn(game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
30472 24267488 }
30473
30474 24267488 void verifyBothWeapons()
30475 {
30476 24267488 verifyAWpn();
30477 24267488 verifyBWpn();
30478 24267488 verifyXWpn();
30479 24267488 verifyYWpn();
30480 24267488 }
30481
30482 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
30483 22790953 int32_t selectSword()
30484 {
30485 22790953 return current_item_id(itype_sword);
30486 }
30487
30488 // Adding code here for allowing hardcoding a button to a specific itemclass.
30489 int32_t selectItemclass(int32_t itemclass)
30490 {
30491 int32_t ret = current_item_id(itemclass);
30492
30493 if(ret == -1)
30494 ret = 0;
30495
30496 return ret;
30497 }
30498
30499 // Used for the 'Pickup Hearts' item pickup condition.
30500 304 bool canget(int32_t id)
30501 {
30502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
30503 }
30504
30505 63 void dospecialmoney(mapscr* scr, int32_t index)
30506 {
30507
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 19 times.
63 if (cur_screen >= 128)
30508 19 scr = special_warp_return_scr;
30509
30510 63 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
30511
30512
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
63 switch (scr->room)
30513 {
30514 case rINFO: // pay for info
30515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
30516 {
30517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!current_item_power(itype_wallet))
30518 {
30519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (game->get_spendable_rupies() < abs(prices[priceindex]))
30520 return;
30521 16 int32_t tmpprice = -abs(prices[priceindex]);
30522 16 int32_t total = game->get_drupy()-tmpprice;
30523 16 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30524 16 game->set_drupy(game->get_drupy()-total);
30525 //game->change_drupy(-abs(prices[priceindex]));
30526 16 }
30527
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( current_item_power(itype_wallet)>0 )
30528 {
30529 game->change_drupy(0);
30530 }
30531 16 }
30532 16 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
30533 16 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
30534 16 donewmsg(scr, QMisc.info[scr->catchall].str[priceindex]);
30535 16 clear_bitmap(pricesdisplaybuf);
30536 16 set_clip_state(pricesdisplaybuf, 1);
30537 16 items.del(0);
30538
30539
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<items.Count(); i++)
30540 48 ((item*)items.spr(i))->pickup=ipDUMMY;
30541
30542 // Prevent the prices from being displayed anymore
30543
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<3; i++)
30544 {
30545 48 prices[i] = 0;
30546 48 }
30547
30548 16 break;
30549
30550 case rMONEY: // secret money
30551 {
30552 20 ((item*)items.spr(0))->pickup = ipDUMMY;
30553
30554 20 prices[0] = scr->catchall;
30555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (!current_item_power(itype_wallet))
30556 20 game->change_drupy(prices[0]);
30557 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
30558
30559 20 putprices(false);
30560
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30561 20 break;
30562 }
30563
30564 case rGAMBLE: // gamble
30565 {
30566 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
30567
30568 unsigned si=(zc_oldrand()%24)*3;
30569
30570 for(int32_t i=0; i<3; i++)
30571 prices[i]=gambledat[si++];
30572
30573 game->set_drupy(game->get_drupy()+prices[priceindex]);
30574 putprices(true);
30575
30576 for(int32_t i=1; i<4; i++)
30577 ((item*)items.spr(i))->pickup=ipDUMMY;
30578 }
30579 break;
30580
30581 case rBOMBS:
30582 {
30583
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
30584 return;
30585
30586 15 int32_t price = -scr->catchall;
30587 15 int32_t wmedal = current_item_id(itype_wealthmedal);
30588
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(wmedal >= 0)
30589 {
30590 if(itemsbuf[wmedal].flags & item_flag1)
30591 price*=(itemsbuf[wmedal].misc1/100.0);
30592 else
30593 price+=itemsbuf[wmedal].misc1;
30594 }
30595
30596 15 int32_t total = game->get_drupy()-price;
30597 15 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30598 15 game->set_drupy(game->get_drupy()-total);
30599 //game->set_drupy(game->get_drupy()+price);
30600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30601 15 game->change_maxbombs(4);
30602 15 game->set_bombs(game->get_maxbombs());
30603 {
30604 15 int32_t div = zinit.bomb_ratio;
30605
30606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(div > 0)
30607 15 game->change_maxcounter(4/div, 6);
30608 }
30609
30610 //also give Hero an actual Bomb item
30611
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 15 times.
3855 for(int32_t i=0; i<MAXITEMS; i++)
30612 {
30613
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
3840 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
30614 15 getitem(i, true, true);
30615 3840 }
30616
30617 15 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
30618 15 fadeclk=66;
30619 15 dismissmsg();
30620 15 clear_bitmap(pricesdisplaybuf);
30621 15 set_clip_state(pricesdisplaybuf, 1);
30622 15 verifyBothWeapons();
30623 15 break;
30624 }
30625
30626 case rARROWS:
30627 {
30628 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
30629 return;
30630
30631 int32_t price = -scr->catchall;
30632 int32_t wmedal = current_item_id(itype_wealthmedal);
30633 if(wmedal >= 0)
30634 {
30635 if(itemsbuf[wmedal].flags & item_flag1)
30636 price*=(itemsbuf[wmedal].misc1/100.0);
30637 else
30638 price+=itemsbuf[wmedal].misc1;
30639 }
30640
30641 int32_t total = game->get_drupy()-price;
30642 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30643 game->set_drupy(game->get_drupy()-total);
30644
30645 //game->set_drupy(game->get_drupy()+price);
30646 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30647 game->change_maxarrows(10);
30648 game->set_arrows(game->get_maxarrows());
30649 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
30650 fadeclk=66;
30651 dismissmsg();
30652 clear_bitmap(pricesdisplaybuf);
30653 set_clip_state(pricesdisplaybuf, 1);
30654 verifyBothWeapons();
30655 break;
30656 }
30657
30658 case rSWINDLE:
30659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(items.spr(index)->id==iRupy)
30660 {
30661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
30662 return;
30663 12 int32_t tmpprice = -scr->catchall;
30664 12 int32_t total = game->get_drupy()-tmpprice;
30665 12 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30666 12 game->set_drupy(game->get_drupy()-total);
30667 12 }
30668 else
30669 {
30670 if(game->get_maxlife()<=game->get_hp_per_heart())
30671 return;
30672
30673 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
30674 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
30675 }
30676
30677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30678 12 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
30679 12 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
30680 12 fadeclk=66;
30681 12 dismissmsg();
30682 12 clear_bitmap(pricesdisplaybuf);
30683 12 set_clip_state(pricesdisplaybuf, 1);
30684 12 break;
30685 }
30686 63 }
30687
30688 24084 void getitem(int32_t id, bool nosound, bool doRunPassive)
30689 {
30690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24084 times.
24084 if(unsigned(id) >= MAXITEMS)
30691 return;
30692
30693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24084 times.
24084 if (replay_is_active())
30694
1/2
✓ Branch 0 taken 24084 times.
✗ Branch 1 not taken.
24084 replay_step_comment(fmt::format("getitem {}", item_string[id]));
30695
30696
2/2
✓ Branch 0 taken 23603 times.
✓ Branch 1 taken 481 times.
24084 if(get_qr(qr_SCC_ITEM_COMBINES_ITEMS))
30697 {
30698 481 int32_t nextitem = -1;
30699 481 do
30700 {
30701 481 nextitem = -1;
30702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
481 if((itemsbuf[id].flags & item_combine) && game->get_item(id))
30703 // Item upgrade routine.
30704 {
30705
30706 for(int32_t i=0; i<MAXITEMS; i++)
30707 {
30708 // Find the item which is as close to this item's fam_type as possible.
30709 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
30710 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
30711 {
30712 nextitem = i;
30713 }
30714 }
30715
30716 if(nextitem>-1)
30717 {
30718 id = nextitem;
30719 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
30720 break; //no looping
30721 }
30722 }
30723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 } while(nextitem > -1);
30724 481 }
30725
30726 24084 itemdata const& idat = itemsbuf[id&0xFF];
30727
30728 48168 bool equipment = idat.flags &
30729 24084 ((idat.family == itype_triforcepiece) ? item_flag8 : item_gamedata);
30730
30731
2/2
✓ Branch 0 taken 19915 times.
✓ Branch 1 taken 4169 times.
24084 if(equipment)
30732 {
30733 // Fix boomerang sounds.
30734 4169 int32_t itemid = current_item_id(idat.family);
30735
30736
4/6
✓ Branch 0 taken 1739 times.
✓ Branch 1 taken 2430 times.
✓ Branch 2 taken 1656 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4169 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
30737
5/6
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1622 times.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 1621 times.
✓ Branch 5 taken 1 times.
1656 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
30738 1739 && sfx_allocated(itemsbuf[itemid].usesound)
30739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 && idat.usesound != itemsbuf[itemid].usesound)
30740 {
30741 stop_sfx(itemsbuf[itemid].usesound);
30742 cont_sfx(idat.usesound);
30743 }
30744
30745 4169 int32_t curitm = current_item_id(idat.family);
30746
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4169 if(!get_qr(qr_KEEPOLD_APPLIES_RETROACTIVELY)
30747
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4165 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
4169 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
30748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 || (itemsbuf[curitm].flags & item_keep_old))
30749 {
30750 4169 game->set_item(id,true);
30751 4169 passiveitem_script(id, doRunPassive);
30752 4169 }
30753
30754
2/2
✓ Branch 0 taken 849 times.
✓ Branch 1 taken 3320 times.
4169 if(!(idat.flags & item_keep_old))
30755 {
30756
4/4
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 2171 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 1109 times.
3320 if(!get_qr(qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
30757 {
30758 2211 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
30759 2211 }
30760 3320 }
30761
30762 // NES consistency: replace all flying boomerangs with the current boomerang.
30763
2/2
✓ Branch 0 taken 4017 times.
✓ Branch 1 taken 152 times.
4169 if(idat.family==itype_brang)
30764
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 for(int32_t i=0; i<Lwpns.Count(); i++)
30765 {
30766 1 weapon *w = ((weapon*)Lwpns.spr(i));
30767
30768
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->id==wBrang)
30769 {
30770 w->LOADGFX(idat.wpn);
30771 }
30772 153 }
30773 4169 }
30774
30775
2/2
✓ Branch 0 taken 4738 times.
✓ Branch 1 taken 19346 times.
24084 if(idat.count!=-1)
30776 {
30777
2/2
✓ Branch 0 taken 18626 times.
✓ Branch 1 taken 720 times.
19346 if(idat.setmax)
30778 {
30779 // Bomb bags are a special case; they may be set not to increase super bombs
30780
5/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 602 times.
✓ Branch 2 taken 118 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 4 times.
720 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
30781 {
30782 4 int32_t max = game->get_maxbombs();
30783
30784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(max<idat.max) max=idat.max;
30785
30786
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
30787 4 }
30788 else
30789 {
30790 716 int32_t max = game->get_maxcounter(idat.count);
30791
30792
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 439 times.
716 if(max<idat.max) max=idat.max;
30793
30794
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 419 times.
716 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
30795 }
30796 720 }
30797
30798 // Amount is an uint16_t, but the range is -9999 to 16383
30799 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
30800
2/2
✓ Branch 0 taken 537 times.
✓ Branch 1 taken 18809 times.
19346 if(idat.amount&0x3FFF)
30801 {
30802
2/2
✓ Branch 0 taken 10789 times.
✓ Branch 1 taken 8020 times.
18809 if(idat.amount&0x8000)
30803 21578 game->set_dcounter(
30804
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10788 times.
10789 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30805 else
30806 {
30807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8020 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8020 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
30808 game->set_counter(0, idat.count);
30809 else
30810 // This is too confusing to try and change...
30811
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8020 times.
✓ Branch 2 taken 3760 times.
✓ Branch 3 taken 4260 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3760 times.
8020 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
30812 }
30813 18809 }
30814 19346 }
30815
30816
2/2
✓ Branch 0 taken 24083 times.
✓ Branch 1 taken 1 times.
24084 if(idat.pickup_litems)
30817 {
30818 1 auto lvl = idat.pickup_litem_level;
30819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(lvl < 0)
30820 1 lvl = dlevel;
30821 1 game->lvlitems[lvl] |= idat.pickup_litems;
30822 1 }
30823
30824
4/4
✓ Branch 0 taken 24046 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 2673 times.
✓ Branch 3 taken 21373 times.
24084 if(idat.playsound&&!nosound)
30825 {
30826 21373 sfx(idat.playsound);
30827 21373 }
30828
30829 //add lower-level items
30830
2/2
✓ Branch 0 taken 23996 times.
✓ Branch 1 taken 88 times.
24084 if(idat.flags&item_gain_old)
30831 {
30832
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 88 times.
195 for(int32_t i=idat.fam_type-1; i>0; i--)
30833 {
30834 107 int32_t potid = getItemID(itemsbuf, idat.family, i);
30835
30836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(potid != -1)
30837 {
30838 107 game->set_item(potid, true);
30839 107 }
30840 107 }
30841 88 }
30842
30843
12/14
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 22167 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 475 times.
✓ Branch 6 taken 128 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 102 times.
✓ Branch 9 taken 89 times.
✓ Branch 10 taken 72 times.
✓ Branch 11 taken 724 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 24 times.
24084 switch(idat.family)
30844 {
30845 case itype_itmbundle:
30846 {
30847
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!itembundle_safe(id & 0xFF))
30848 break;
30849 24 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
30850 20 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
30851 4 bool pscript = (idat.flags & item_flag1);
30852
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 4 times.
44 for(auto q = 0; q < 10; ++q)
30853 {
30854
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(unsigned(ids[q]) >= MAXITEMS) continue;
30855
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 10 times.
33 if(pscript)
30856 10 collectitem_script(ids[q]);
30857
30858 33 getitem(ids[q], true, true);
30859 33 }
30860 }
30861 4 break;
30862
30863 case itype_progressive_itm:
30864 {
30865 int32_t newid = get_progressive_item(id);
30866 if(newid > -1)
30867 getitem(newid, nosound, true);
30868 }
30869 break;
30870
30871 case itype_bottlefill:
30872 {
30873 if(idat.misc1)
30874 {
30875 game->fillBottle(idat.misc1);
30876 }
30877 }
30878 break;
30879
30880 case itype_clock:
30881 {
30882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(idat.flags & item_flag1) //Active use, not passive
30883 break;
30884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
475 if((idat.flags & item_flag2) && clockclk) //"Can't activate while clock active"
30885 break;
30886 475 setClock(watch=true);
30887
30888 475 clock_zoras.clear();
30889
30890 475 clockclk=idat.misc1;
30891 475 sfx(idat.usesound);
30892 }
30893 475 break;
30894
30895 case itype_lkey:
30896 {
30897 128 auto lvl = dlevel;
30898
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(idat.flags & item_flag1) // custom level
30899 lvl = vbound(idat.misc1, 0, MAXLEVELS-1);
30900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(game->lvlkeys[lvl]<255)
30901 128 game->lvlkeys[lvl]++;
30902 128 break;
30903 }
30904
30905 case itype_ring:
30906 case itype_magicring:
30907
6/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 2 times.
175 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (cur_screen<128 || dlevel))
30908 {
30909 173 ringcolor(false);
30910 173 }
30911 175 break;
30912
30913 case itype_whispring:
30914 {
30915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & item_flag1)
30916 {
30917
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
30918
30919
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
30920
30921
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()== 1) setShieldClk(150); // Let's not bother applying the divisor.
30922 5 }
30923
30924
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if(idat.power==0)
30925 {
30926 2 setSwordClk(0);
30927 2 setItemClk(0);
30928 2 setShieldClk(0);
30929 2 }
30930
30931 5 break;
30932 }
30933
30934
30935 case itype_map:
30936 102 game->lvlitems[dlevel]|=liMAP;
30937 102 break;
30938
30939 case itype_compass:
30940 89 game->lvlitems[dlevel]|=liCOMPASS;
30941 89 break;
30942
30943 case itype_bosskey:
30944 72 game->lvlitems[dlevel]|=liBOSSKEY;
30945 72 break;
30946
30947 case itype_fairy:
30948
30949
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
724 game->set_life(zc_min(game->get_life()+(idat.flags&item_flag1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
30950
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 609 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
724 game->set_magic(zc_min(game->get_magic()+(idat.flags&item_flag2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
30951 724 break;
30952
30953 case itype_heartpiece:
30954 119 game->change_HCpieces(1);
30955
30956
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 26 times.
119 if(game->get_HCpieces()<game->get_hcp_per_hc())
30957 93 break;
30958
30959 26 game->set_HCpieces(0);
30960
30961 26 getitem(heart_container_id());
30962 26 break;
30963
30964 case itype_killem:
30965 {
30966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(idat.flags & item_flag1) //Active use, not passive
30967 break;
30968 24 kill_em_all();
30969 24 sfx(idat.usesound);
30970 }
30971 24 break;
30972 }
30973
30974 24084 flushItemCache();
30975 24084 update_subscreens();
30976 24084 refresh_subscr_items();
30977 24084 verifyBothWeapons();
30978 24084 }
30979
30980 11 void takeitem(int32_t id)
30981 {
30982 11 game->set_item(id, false);
30983 11 itemdata const& idat = itemsbuf[id];
30984
30985 /* Lower the counters! */
30986
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(idat.count!=-1)
30987 {
30988 if(idat.setmax)
30989 {
30990 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
30991 }
30992
30993 if(idat.amount&0x3FFF)
30994 {
30995 if(idat.amount&0x8000)
30996 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30997 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
30998 }
30999 }
31000
31001
1/10
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11 switch(itemsbuf[id&0xFF].family)
31002 {
31003 // NES consistency: replace all flying boomerangs with the current boomerang.
31004 case itype_brang:
31005 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
31006 {
31007 weapon *w = ((weapon*)Lwpns.spr(i));
31008
31009 if(w->id==wBrang)
31010 {
31011 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
31012 }
31013 }
31014
31015 break;
31016
31017 case itype_itmbundle:
31018 {
31019 if(!itembundle_safe(id))
31020 break;
31021 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
31022 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
31023 for(auto q = 0; q < 10; ++q)
31024 {
31025 if(unsigned(ids[q]) >= MAXITEMS) continue;
31026 takeitem(ids[q]);
31027 }
31028 }
31029 break;
31030
31031 case itype_progressive_itm:
31032 {
31033 int32_t newid = get_progressive_item(id, true);
31034 if(newid > -1)
31035 takeitem(newid);
31036 }
31037 break;
31038
31039 case itype_heartpiece:
31040 if(game->get_maxlife()>game->get_hp_per_heart())
31041 {
31042 if(game->get_HCpieces()==0)
31043 {
31044 game->set_HCpieces(game->get_hcp_per_hc());
31045 takeitem(iHeartC);
31046 }
31047
31048 game->change_HCpieces(-1);
31049 }
31050 break;
31051
31052 case itype_map:
31053 game->lvlitems[dlevel]&=~liMAP;
31054 break;
31055
31056 case itype_compass:
31057 game->lvlitems[dlevel]&=~liCOMPASS;
31058 break;
31059
31060 case itype_bosskey:
31061 game->lvlitems[dlevel]&=~liBOSSKEY;
31062 break;
31063
31064 case itype_lkey:
31065 {
31066 auto lvl = dlevel;
31067 if(idat.flags & item_flag1) // custom level
31068 lvl = vbound(idat.misc1, 0, MAXLEVELS-1);
31069 if(game->lvlkeys[lvl])
31070 game->lvlkeys[lvl]--;
31071 break;
31072 }
31073
31074 case itype_ring:
31075 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (cur_screen<128 || dlevel))
31076 {
31077 ringcolor(false);
31078 }
31079 break;
31080 }
31081 11 }
31082
31083 14238 void post_item_collect()
31084 {
31085 14238 std::vector<int32_t> &ev = FFCore.eventData;
31086 14238 ev.clear();
31087
31088 14238 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
31089 14238 }
31090
31091 14459 void HeroClass::handle_triforce(mapscr* scr, int32_t id)
31092 {
31093
1/2
✓ Branch 0 taken 14459 times.
✗ Branch 1 not taken.
14459 if(unsigned(id) >= MAXITEMS)
31094 return;
31095 14459 itemdata const& itm = itemsbuf[id];
31096
3/3
✓ Branch 0 taken 14340 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 115 times.
14459 switch(itm.family)
31097 {
31098 case itype_itmbundle:
31099 {
31100
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!itembundle_safe(id, true)) // skip error because it will always have already printed earlier this frame in 'getitem'
31101 break;
31102 24 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
31103 20 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
31104
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 4 times.
44 for(auto q = 0; q < 10; ++q)
31105 {
31106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(unsigned(ids[q]) >= MAXITEMS) continue;
31107 33 handle_triforce(scr, ids[q]);
31108 33 }
31109 }
31110 4 break;
31111 case itype_triforcepiece:
31112 {
31113
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 100 times.
115 if(itm.misc2>0)
31114 100 getTriforce(id); //small
31115 15 else getBigTri(scr, id); //big
31116 }
31117 115 break;
31118 }
31119 14459 }
31120
31121 // Attempt to pick up an item. (-1 = check items touching Hero.)
31122 14285103 void HeroClass::checkitems(int32_t index)
31123 {
31124
2/2
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 14283254 times.
14285103 if(index==-1)
31125 {
31126
2/2
✓ Branch 0 taken 3062608 times.
✓ Branch 1 taken 14283254 times.
17345862 for(auto ind = items.Count()-1; ind >= 0; --ind)
31127 {
31128 3062608 item* itm = (item*)items.spr(ind);
31129
2/2
✓ Branch 0 taken 3062546 times.
✓ Branch 1 taken 62 times.
3062608 if(itm->get_forcegrab())
31130 {
31131 62 checkitems(ind);
31132 62 }
31133 3062608 }
31134
4/6
✓ Branch 0 taken 9737625 times.
✓ Branch 1 taken 4545629 times.
✓ Branch 2 taken 9737625 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9737625 times.
14283254 if(diagonalMovement || NO_GRIDLOCK)
31135 {
31136 4545629 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
31137 4545629 }
31138 9737625 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
31139 14283254 }
31140
31141
2/2
✓ Branch 0 taken 120463 times.
✓ Branch 1 taken 14164640 times.
14285103 if(index==-1)
31142 14164640 return;
31143
31144 120463 item* ptr = (item*)items.spr(index);
31145 120463 int32_t pickup = ptr->pickup;
31146 120463 int8_t exstate = ptr->pickupexstate;
31147 120463 int32_t PriceIndex = ptr->PriceIndex;
31148 120463 int32_t id2 = ptr->id;
31149 120463 int32_t holdid = ptr->id;
31150 120463 int32_t pstr = ptr->pstring;
31151 120463 int32_t pstr_flags = ptr->pickup_string_flags;
31152 120463 int32_t linked_parent = ptr->linked_parent;
31153 // `screen_spawned` is probably same as `heroscr`, but could not be if the item moved around.
31154 120463 int32_t item_screen = ptr->screen_spawned;
31155 120463 mapscr* item_scr = get_scr_maybe(cur_map, item_screen);
31156
31157 // I haven't observed this happening, but there are crash reports showing that an
31158 // item sprite does not have a screen_spawned for the current screens.
31159 // Only guess is that `set_forcegrab` kept the item around from the previous screen.
31160 // https://zeldaclassic.sentry.io/share/issue/c13f5a3c5079463fb6901cfea26c695a/
31161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120463 times.
120463 if (!item_scr)
31162 {
31163 item_screen = get_screen_for_world_xy(ptr->x, ptr->y);
31164 item_scr = get_scr(item_screen);
31165 }
31166
31167 // For items grabbed while in a special screen.
31168
2/2
✓ Branch 0 taken 118898 times.
✓ Branch 1 taken 1565 times.
120463 if (cur_screen >= 128)
31169 1565 item_scr = special_warp_return_scr;
31170
31171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120463 times.
120463 if(ptr->fallclk > 0) return; //Don't pick up a falling item
31172
31173
1/2
✓ Branch 0 taken 120463 times.
✗ Branch 1 not taken.
120463 if(itemsbuf[id2].family == itype_progressive_itm)
31174 {
31175 int32_t newid = get_progressive_item(id2);
31176 if(newid > -1)
31177 {
31178 id2 = newid;
31179 holdid = newid;
31180 pstr = itemsbuf[newid].pstring;
31181 pstr_flags = itemsbuf[newid].pickup_string_flags;
31182 }
31183 }
31184
31185
2/2
✓ Branch 0 taken 119437 times.
✓ Branch 1 taken 1026 times.
120463 bool bottledummy = (pickup&ipCHECK) && item_scr->room == rBOTTLESHOP;
31186
31187
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 120430 times.
120463 if(bottledummy) //Dummy bullshit!
31188 {
31189
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!game->canFillBottle())
31190 return;
31191
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
31192 {
31193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
31194 {
31195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
31196 1 int32_t tmpprice = -abs(prices[PriceIndex]);
31197 //game->change_drupy(-abs(prices[priceindex]));
31198 1 int32_t total = game->get_drupy()-tmpprice;
31199 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31200 1 game->set_drupy(game->get_drupy()-total);
31201 1 }
31202 else //infinite wallet
31203 {
31204 game->change_drupy(0);
31205 }
31206 1 }
31207 33 boughtsomething=true;
31208 //make the other shop items untouchable after
31209 //you buy something
31210
31211
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 33 times.
37 for(int32_t i=0; i<items.Count(); i++)
31212 {
31213
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
31214 2 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
31215 4 }
31216
31217 33 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[item_scr->catchall].fill[PriceIndex]);
31218 33 id2 = find_bottle_for_slot(slot);
31219 33 ptr->id = id2;
31220 33 holdid = id2;
31221 33 pstr = 0;
31222 33 pickup |= ipHOLDUP;
31223 33 }
31224 else
31225 {
31226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120430 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
31227 return; //No picking these up unless you have a bottle to fill!
31228
31229
5/6
✓ Branch 0 taken 115173 times.
✓ Branch 1 taken 5257 times.
✓ Branch 2 taken 103751 times.
✓ Branch 3 taken 11422 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 103751 times.
120430 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
31230
2/2
✓ Branch 0 taken 103546 times.
✓ Branch 1 taken 205 times.
103751 if(ptr->id!=iFairyMoving)
31231 // wait for it to stop flashing, doesn't check for other items yet
31232 103546 return;
31233
31234
2/2
✓ Branch 0 taken 16827 times.
✓ Branch 1 taken 57 times.
16884 if(pickup&ipENEMY) // item was being carried by enemy
31235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
114 if(more_carried_items(item_screen)<=1) // 1 includes this own item.
31236 57 screen_item_set_state(item_screen, ScreenItemState::None);
31237
31238
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 15181 times.
16884 if(pickup&ipDUMMY) // dummy item (usually a rupee)
31239 {
31240
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 63 times.
1703 if(pickup&ipMONEY)
31241 63 dospecialmoney(item_scr, index);
31242
31243 1703 return;
31244 }
31245
31246
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 15086 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
15181 if(get_qr(qr_HEARTSREQUIREDFIX) && !canget(id2))
31247 return;
31248
31249 15181 int32_t nextitem = -1;
31250 15181 do
31251 {
31252 15181 nextitem = -1;
31253
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15156 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
15181 if((itemsbuf[id2].flags & item_combine) && game->get_item(id2))
31254 // Item upgrade routine.
31255 {
31256
31257
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<MAXITEMS; i++)
31258 {
31259 // Find the item which is as close to this item's fam_type as possible.
31260
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3553 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
3584 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
31261
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
31 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
31262 {
31263 14 nextitem = i;
31264 14 }
31265 3584 }
31266
31267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(nextitem>-1)
31268 {
31269 14 id2 = nextitem;
31270
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(get_qr(qr_ITEMCOMBINE_NEW_PSTR))
31271 {
31272 pstr = itemsbuf[id2].pstring;
31273 pstr_flags = itemsbuf[id2].pickup_string_flags;
31274 }
31275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
31276 14 break; //no looping
31277 }
31278 }
31279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
15167 } while(nextitem > -1);
31280
31281
2/2
✓ Branch 0 taken 14156 times.
✓ Branch 1 taken 1025 times.
15181 if(pickup&ipCHECK) // check restrictions
31282
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 209 times.
✓ Branch 3 taken 107 times.
1025 switch(item_scr->room)
31283 {
31284 case rSP_ITEM: // special item
31285
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
209 if(!canget(id2)) // These ones always need the Hearts Required check
31286 63 return;
31287
31288 146 break;
31289
31290 case rP_SHOP: // potion shop
31291
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
31292 93 return;
31293 [[fallthrough]];
31294 case rSHOP: // shop
31295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
31296 {
31297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(!current_item_power(itype_wallet))
31298 {
31299
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 123 times.
723 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
31300 123 int32_t tmpprice = -abs(prices[PriceIndex]);
31301 //game->change_drupy(-abs(prices[priceindex]));
31302 123 int32_t total = game->get_drupy()-tmpprice;
31303 123 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31304 123 game->set_drupy(game->get_drupy()-total);
31305 123 }
31306 else //infinite wallet
31307 {
31308 game->change_drupy(0);
31309 }
31310 123 }
31311 123 boughtsomething=true;
31312 //make the other shop items untouchable after
31313 //you buy something
31314 123 int32_t count = 0;
31315
31316
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 123 times.
492 for(int32_t i=0; i<3; i++)
31317 {
31318
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 324 times.
369 if(QMisc.shop[item_scr->catchall].hasitem[i] != 0)
31319 {
31320 324 ++count;
31321 324 }
31322 369 }
31323
31324
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 123 times.
573 for(int32_t i=0; i<items.Count(); i++)
31325 {
31326
4/4
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 201 times.
450 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
31327 201 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
31328 450 }
31329
31330 123 break;
31331 269 }
31332
31333 //EVENT
31334 {
31335 14425 std::vector<int32_t> &ev = FFCore.eventData;
31336 14425 ev.clear();
31337 14425 ev.push_back(id2*10000);
31338 14425 ev.push_back(pickup*10000);
31339 14425 ev.push_back(pstr*10000);
31340 14425 ev.push_back(pstr_flags*10000);
31341 14425 ev.push_back(0);
31342 14425 ev.push_back(ptr->getUID());
31343 14425 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
31344 14425 ev.push_back(0);
31345
31346 14425 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
31347 14425 bool nullify = ev[4] != 0;
31348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14425 times.
14425 if(nullify) return;
31349 14425 id2 = ev[0]/10000;
31350 14425 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
31351 14425 pstr = ev[2] / 10000;
31352 14425 pstr_flags = ev[3] / 10000;
31353 }
31354
31355
2/2
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 12868 times.
14425 if(pickup&ipONETIME) // set mITEM for one-time-only items
31356 {
31357 1557 setmapflag(item_scr, mITEM);
31358
31359 //Okay so having old source files is a godsend. You wanna know why?
31360 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
31361 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
31362 //The default would be mITEM if cur_screen was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
31363 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
31364 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
31365
31366 /*
31367 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
31368 // broken behavior from early ZC versions. If you change things here please comment on its purpose.
31369
31370 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
31371 // What is etc?! We need to check for every valid state here. ~Gleeok
31372 if(get_qr(qr_ITEMPICKUPSETSBELOW))
31373 {
31374 // Most older quests need one-time-pickups to not remove special items, etc.
31375 if(origin_scr->room==rGRUMBLE)
31376 {
31377 setmapflag(mSPECIALITEM);
31378 }
31379 }
31380 */
31381 1557 }
31382
2/2
✓ Branch 0 taken 12102 times.
✓ Branch 1 taken 766 times.
12868 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
31383
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 504 times.
766 setmapflag(item_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
31384
31385
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14425 if(exstate > -1 && exstate < 32)
31386 {
31387 2 setxmapflag(item_screen, 1<<exstate);
31388 2 }
31389
31390
2/2
✓ Branch 0 taken 14424 times.
✓ Branch 1 taken 1 times.
14425 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
31391 {
31392
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (item_scr->flags9&fITEMSECRETPERM) setmapflag(item_scr, mSECRET);
31393 1 trigger_secrets_for_screen(TriggerSource::ItemsSecret, item_scr, false);
31394 1 }
31395
31396 14425 collectitem_script(id2);
31397 14425 getitem(id2, ptr->noSound, true);
31398 }
31399
31400
2/2
✓ Branch 0 taken 1561 times.
✓ Branch 1 taken 12893 times.
14458 if(pickup&ipHOLDUP)
31401 {
31402 1561 attackclk=0;
31403 1561 reset_swordcharge();
31404
31405
3/4
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1516 times.
1561 if(action!=swimming && !IsSideSwim())
31406 1516 reset_hookshot();
31407
31408
2/2
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 280 times.
1561 if(msg_onscreen)
31409 {
31410 280 dismissmsg();
31411 280 }
31412
31413 1481 clear_bitmap(pricesdisplaybuf);
31414
31415
7/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1323 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 68 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 66 times.
✓ Branch 7 taken 144 times.
1528 if(get_qr(qr_OLDPICKUP) || ((item_scr->room==rSP_ITEM || item_scr->room==rRP_HC || item_scr->room==rTAKEONE) && (pickup&ipONETIME2)) ||
31416
4/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1 times.
144 (get_qr(qr_SHOP_ITEMS_VANISH) && (item_scr->room==rBOTTLESHOP || item_scr->room==rSHOP) && (pickup&ipCHECK)))
31417 {
31418 1436 fadeclk=66;
31419 1436 }
31420
31421
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 12 times.
1533 if(id2!=iBombs || action==swimming || get_qr(qr_BOMBHOLDFIX))
31422 {
31423 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
31424
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1504 times.
1521 if(action==swimming)
31425 {
31426 17 action=waterhold1; FFCore.setHeroAction(waterhold1);
31427 17 }
31428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 else if(IsSideSwim())
31429 {
31430 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
31431 }
31432 else
31433 {
31434 1504 action=landhold1; FFCore.setHeroAction(landhold1);
31435 }
31436
31437
2/2
✓ Branch 0 taken 1168 times.
✓ Branch 1 taken 353 times.
1521 if(ptr->twohand)
31438 {
31439
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 347 times.
353 if(action==waterhold1)
31440 {
31441 6 action=waterhold2; FFCore.setHeroAction(waterhold2);
31442 6 }
31443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 347 times.
347 else if(action==sidewaterhold1)
31444 {
31445 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
31446 }
31447 else
31448 {
31449 347 action=landhold2; FFCore.setHeroAction(landhold2);
31450 }
31451 353 }
31452
31453 1521 holdclk=130;
31454
31455 //restart music
31456
2/2
✓ Branch 0 taken 1411 times.
✓ Branch 1 taken 110 times.
1521 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0)
31457 110 music_stop();
31458
31459 1521 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
31460 1521 freeze_guys=true;
31461 //show the info string
31462
31463
31464 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
31465
31466 1521 int32_t shop_pstr = 0;
31467
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1379 times.
1521 if (PriceIndex > -1)
31468 {
31469
3/3
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 1 times.
142 switch(item_scr->room)
31470 {
31471 case rSHOP:
31472 109 shop_pstr = QMisc.shop[item_scr->catchall].str[PriceIndex];
31473 109 break;
31474 case rBOTTLESHOP:
31475 1 shop_pstr = QMisc.bottle_shop_types[item_scr->catchall].str[PriceIndex];
31476 1 break;
31477 }
31478 142 }
31479
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1502 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1501 times.
1521 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
31480 {
31481
9/12
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
20 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
31482 {
31483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
31484 19 }
31485 1 else pstr = 0;
31486
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
20 if(shop_pstr)
31487 {
31488 1 donewmsg(item_scr, shop_pstr);
31489 1 enqueued_str = pstr;
31490 1 }
31491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 else if(pstr)
31492 {
31493 19 donewmsg(item_scr, pstr);
31494 19 }
31495 20 }
31496
31497 1521 }
31498
31499
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1429 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4 times.
1533 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & item_gamedata))
31500 {
31501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1433 times.
1433 if (!ptr->noHoldSound) sfx(item_scr->holdupsfx);
31502 1433 }
31503
31504 1533 ptr->set_forcegrab(false);
31505 1533 items.del(index);
31506
31507
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 1533 times.
1760 for(int32_t i=0; i<Lwpns.Count(); i++)
31508 {
31509 227 weapon *w = (weapon*)Lwpns.spr(i);
31510
31511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(w->dragging==index)
31512 {
31513 w->dragging=-1;
31514 }
31515
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 else if(w->dragging>index)
31516 {
31517 w->dragging-=1;
31518 }
31519 227 }
31520
31521 // clear up shop stuff
31522
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 717 times.
✓ Branch 3 taken 127 times.
1533 if((isdungeon()==0)&&(index!=0))
31523 {
31524
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 83 times.
127 if(boughtsomething)
31525 {
31526 83 fadeclk=66;
31527
31528
3/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
83 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
31529 {
31530 80 items.del(0);
31531
31532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 for(int32_t i=0; i<Lwpns.Count(); i++)
31533 {
31534 weapon *w = (weapon*)Lwpns.spr(i);
31535
31536 if(w->dragging==0)
31537 {
31538 w->dragging=-1;
31539 }
31540 else if(w->dragging>0)
31541 {
31542 w->dragging-=1;
31543 }
31544 }
31545 80 }
31546 83 }
31547
31548
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(msg_onscreen)
31549 {
31550 dismissmsg();
31551 }
31552
31553 127 clear_bitmap(pricesdisplaybuf);
31554 127 set_clip_state(pricesdisplaybuf, 1);
31555 127 }
31556
31557 // items.del(index);
31558 1533 }
31559 else
31560 {
31561 12893 ptr->set_forcegrab(false);
31562 12893 items.del(index);
31563
31564
2/2
✓ Branch 0 taken 9184 times.
✓ Branch 1 taken 12893 times.
22077 for(int32_t i=0; i<Lwpns.Count(); i++)
31565 {
31566 9184 weapon *w = (weapon*)Lwpns.spr(i);
31567
31568
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 8694 times.
9184 if(w->dragging==index)
31569 {
31570 490 w->dragging=-1;
31571 490 }
31572
2/2
✓ Branch 0 taken 8690 times.
✓ Branch 1 taken 4 times.
8694 else if(w->dragging>index)
31573 {
31574 4 w->dragging-=1;
31575 4 }
31576 9184 }
31577
31578
2/2
✓ Branch 0 taken 12880 times.
✓ Branch 1 taken 13 times.
12893 if(msg_onscreen)
31579 {
31580 13 dismissmsg();
31581 13 }
31582
31583 //general item pickup message
31584 //show the info string
31585 //non-held
31586 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
31587
3/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 12757 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12893 int32_t shop_pstr = ( item_scr->room == rSHOP && PriceIndex>=0 && QMisc.shop[item_scr->catchall].str[PriceIndex] > 0 ) ? QMisc.shop[item_scr->catchall].str[PriceIndex] : 0;
31588
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12891 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12891 times.
12893 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
31589 {
31590
7/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
2 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
31591 {
31592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
31593 1 }
31594 1 else pstr = 0;
31595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(shop_pstr)
31596 {
31597 donewmsg(item_scr, shop_pstr);
31598 enqueued_str = pstr;
31599 }
31600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(pstr)
31601 {
31602 1 donewmsg(item_scr, pstr);
31603 1 }
31604 2 }
31605
31606
31607 12893 clear_bitmap(pricesdisplaybuf);
31608 12893 set_clip_state(pricesdisplaybuf, 1);
31609 }
31610
31611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11 times.
14441 if(itemsbuf[id2].family==itype_triforcepiece
31612
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14311 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 100 times.
14426 && itemsbuf[id2].misc2 <= 0 && linked_parent == eeGANON)
31613 {
31614 11 game->lvlitems[dlevel]|=liBOSS;
31615 11 }
31616 14426 handle_triforce(item_scr, id2);
31617
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 12980 times.
14426 if(!holdclk)
31618 12980 post_item_collect();
31619 14285071 }
31620
31621 294 void HeroClass::StartRefill(int32_t refillWhat)
31622 {
31623
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 if(FFCore.quest_format[vZelda] < 0x255)
31624 {
31625 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
31626 //I attempted to change this check to a quest rule, but here's the issue: this affects
31627 //triforces and potions as well, not just fairy flags. This means that having a compat rule
31628 //would result in a rule that is checked by default for every tileset or quest made before
31629 //2.55, one in a place most people won't check. That means that if they were to go to use
31630 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
31631 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
31632 //"go through the compat rules and turn them all off", so this remains a version check instead
31633 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
31634 276 Start250Refill(refillWhat);
31635 276 return;
31636 }
31637
31638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!refilling)
31639 {
31640 18 refillclk=21;
31641 18 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
31642 18 sfx(WAV_REFILL,128,true);
31643 18 refilling=refillWhat;
31644
31645
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(refill_why>=0) // Item index
31646 {
31647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].family==itype_potion)
31648 {
31649 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
31650 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
31651 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
31652 }
31653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(itemsbuf[refill_why].family==itype_triforcepiece)
31654 {
31655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
31656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
31657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
31658 9 }
31659 9 }
31660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(refill_why==REFILL_FAIRY)
31661 {
31662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_qr(qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
31663
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(get_qr(qr_ITEMBUBBLE))itemclk=0;
31664
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_qr(qr_SHIELDBUBBLE))shieldjinxclk=0;
31665 9 }
31666 18 }
31667 294 }
31668
31669 276 void HeroClass::Start250Refill(int32_t refillWhat)
31670 {
31671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 if(!refilling)
31672 {
31673 276 refillclk=21;
31674 276 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
31675 276 sfx(WAV_REFILL,128,true);
31676 276 refilling=refillWhat;
31677
31678 // For ~2 years <2.55 quests were broken, never restoring anything on fairies.
31679 // https://discord.com/channels/876899628556091432/1275805052006563861
31680
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
276 if (replay_is_active() && replay_version_check(0, 35))
31681 {
31682
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
276 std::string qst = replay_get_meta_str("qst");
31683
9/12
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 201 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 201 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 23 times.
✓ Branch 11 taken 178 times.
276 if (qst == "first_quest_layered.qst" || qst == "nes_remastered.qst" || qst == "demosp253.qst")
31684 98 return;
31685
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 178 times.
276 }
31686
31687
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 92 times.
178 if(refill_why>=0) // Item index
31688 {
31689
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 7 times.
86 if((itemsbuf[refill_why].family==itype_potion)&&(!get_qr(qr_NONBUBBLEMEDICINE)))
31690 {
31691 7 swordclk=0;
31692 7 verifyAWpn();
31693
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
31694 7 }
31695
31696
4/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 57 times.
86 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_qr(qr_NONBUBBLETRIFORCE)))
31697 {
31698 57 swordclk=0;
31699 57 verifyAWpn();
31700
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1 times.
57 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
31701 57 }
31702 86 }
31703
3/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 54 times.
92 else if((refill_why==REFILL_FAIRY)&&(!get_qr(qr_NONBUBBLEFAIRIES)))
31704 {
31705 54 swordclk=0;
31706 54 verifyAWpn();
31707
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
31708 54 }
31709 178 }
31710 276 }
31711
31712 377716 bool HeroClass::refill()
31713 {
31714
4/4
✓ Branch 0 taken 22058 times.
✓ Branch 1 taken 355658 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 21422 times.
377716 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
31715 {
31716 356294 return false;
31717 }
31718
31719 21422 ++refillclk;
31720 21422 int32_t speed = get_qr(qr_FASTFILL) ? 6 : 22;
31721 21422 int32_t refill_heart_stop=game->get_maxlife();
31722 21422 int32_t refill_magic_stop=game->get_maxmagic();
31723
31724
4/4
✓ Branch 0 taken 10865 times.
✓ Branch 1 taken 10557 times.
✓ Branch 2 taken 4542 times.
✓ Branch 3 taken 6323 times.
21422 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
31725 {
31726
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & item_flag1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
31727
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & item_flag2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
31728 6323 }
31729
31730
2/2
✓ Branch 0 taken 18948 times.
✓ Branch 1 taken 2474 times.
21422 if(refillclk%speed == 0)
31731 {
31732 // game->life&=0xFFC;
31733
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1194 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1277 times.
2474 switch(refill_what)
31734 {
31735 case REFILL_LIFE:
31736
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1139 times.
1194 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
31737
31738
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 1038 times.
1194 if(game->get_life()>=refill_heart_stop)
31739 {
31740 156 game->set_life(refill_heart_stop);
31741 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31742
2/2
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 156 times.
40092 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31743 {
31744
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 39780 times.
39936 if ( q == (int32_t)hero_scr->oceansfx ) continue;
31745
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 39779 times.
39780 if ( q == (int32_t)hero_scr->bosssfx ) continue;
31746 39779 stop_sfx(q);
31747 39779 }
31748 156 sfx(QMisc.miscsfx[sfxREFILL]);
31749 156 refilling=REFILL_NONE;
31750 156 return false;
31751 }
31752
31753 1038 break;
31754
31755 case REFILL_MAGIC:
31756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
31757
31758
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(game->get_magic()>=refill_magic_stop)
31759 {
31760 1 game->set_magic(refill_magic_stop);
31761 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31762
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31763 {
31764
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
256 if ( q == (int32_t)hero_scr->oceansfx ) continue;
31765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if ( q == (int32_t)hero_scr->bosssfx ) continue;
31766 255 stop_sfx(q);
31767 255 }
31768 1 sfx(QMisc.miscsfx[sfxREFILL]);
31769 1 refilling=REFILL_NONE;
31770 1 return false;
31771 }
31772
31773 2 break;
31774
31775 case REFILL_ALL:
31776
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1181 times.
1277 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
31777
2/2
✓ Branch 0 taken 1187 times.
✓ Branch 1 taken 90 times.
1277 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
31778
31779
4/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 21 times.
1277 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
31780 {
31781 137 game->set_life(refill_heart_stop);
31782 137 game->set_magic(refill_magic_stop);
31783 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
31784
2/2
✓ Branch 0 taken 35072 times.
✓ Branch 1 taken 137 times.
35209 for ( int32_t q = 0; q < WAV_COUNT; q++ )
31785 {
31786
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 34935 times.
35072 if ( q == (int32_t)hero_scr->oceansfx ) continue;
31787
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 34915 times.
34935 if ( q == (int32_t)hero_scr->bosssfx ) continue;
31788 34915 stop_sfx(q);
31789 34915 }
31790 137 sfx(QMisc.miscsfx[sfxREFILL]);
31791 137 refilling=REFILL_NONE;
31792 137 return false;
31793 }
31794
31795 1140 break;
31796 }
31797 2180 }
31798
31799 21128 return true;
31800 377716 }
31801
31802 100 void HeroClass::getTriforce(int32_t id2)
31803 {
31804
31805 PALETTE flash_pal;
31806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
31807
31808
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<256; i++)
31809 {
31810
2/2
✓ Branch 0 taken 15616 times.
✓ Branch 1 taken 9984 times.
25600 flash_pal[i] = get_qr(qr_FADE) ? _RGB(255,255,0) : _RGB(255,255,255);
31811 25600 }
31812
31813
31814
31815 //get rid off all sprites but Hero
31816 100 guys.clear();
31817 100 items.clear();
31818 100 Ewpns.clear();
31819 100 Lwpns.clear();
31820 100 chainlinks.clear();
31821
31822 100 kill_subscr_items();
31823
31824 100 sfx(itemsbuf[id2].playsound);
31825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if ( !(itemsbuf[id2].flags & item_flag11) ) music_stop();
31826
31827 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
31828
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if ( (itemsbuf[id2].flags & item_flag14) )
31829 {
31830 uint8_t playwav = itemsbuf[id2].misc3;
31831 sfx(playwav);
31832
31833 }
31834
31835 //itemsbuf[id2].flags & item_flag9 : Don't dismiss Messages
31836 //itemsbuf[id2].flags & item_flag10 : Cutscene interrupts action script..
31837 //itemsbuf[id2].flags & item_flag11 : Don't change music.
31838 //itemsbuf[id2].flags & item_flag12 : Run Collect Script Script On Collection
31839 //itemsbuf[id2].flags & item_flag13 : Run Action Script On Collection
31840 //itemsbuf[id2].flags & item_flag14 : Play second sound (WAV) from Attributes[2] (misc2)
31841 //itemsbuf[id2].flags & item_flag15 : No MIDI
31842
31843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(itemsbuf[id2].flags & item_flag15)) //No MIDI flag
31844 {
31845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].misc1)
31846 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
31847 else
31848 100 try_zcmusic("zelda.nsf",qstpath,5,ZC_MIDI_TRIFORCE,get_emusic_volume());
31849 100 }
31850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].flags & item_gamedata)
31851 {
31852 100 game->lvlitems[dlevel]|=liTRIFORCE;
31853 100 }
31854
31855 100 int32_t f=0;
31856 100 int32_t x2=0;
31857 100 int32_t curtain_x=0;
31858 100 int32_t c=0;
31859
31860 100 do
31861 {
31862
31863
31864
1/2
✓ Branch 0 taken 52360 times.
✗ Branch 1 not taken.
52360 if ( (itemsbuf[id2].flags & item_flag13) ) //Run action script on collection.
31865 {
31866 if ( itemsbuf[id2].script )
31867 {
31868 if ( !FFCore.doscript(ScriptType::Item, id2) )
31869 {
31870 int i = id2;
31871 FFCore.reset_script_engine_data(ScriptType::Item, i);
31872 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
31873 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
31874 }
31875 else
31876 {
31877 if ( !(itemsbuf[id2].flags & item_flag10) ) //Cutscene halts the script it resumes after cutscene.
31878 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
31879 }
31880 }
31881 }
31882 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
31883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if ( (itemsbuf[id2].flags & item_flag12) ) //No cutscene
31884 {
31885 return;
31886 }
31887
31888
2/2
✓ Branch 0 taken 32594 times.
✓ Branch 1 taken 19766 times.
52360 if(!COOLSCROLL)
31889 {
31890 19766 show_subscreen_items=false;
31891 19766 }
31892
31893
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==40)
31894 {
31895 100 actiontype oldaction = action;
31896 100 ALLOFF((!(itemsbuf[id2].flags & item_flag9)), false);
31897 100 action=oldaction; // have to reset this flag
31898 100 FFCore.setHeroAction(oldaction);
31899 100 }
31900
31901
31902
4/4
✓ Branch 0 taken 48360 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 43560 times.
✓ Branch 3 taken 4800 times.
52360 if(f>=40 && f<88)
31903 {
31904
2/2
✓ Branch 0 taken 2928 times.
✓ Branch 1 taken 1872 times.
4800 if(get_qr(qr_FADE))
31905 {
31906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2928 if (!flash_reduction_enabled() && (f&7) == 0)
31907 {
31908 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
31909 refreshpal=true;
31910 }
31911
31912
2/2
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 732 times.
2928 if((f&3)==2)
31913 {
31914 732 loadpalset(0,0);
31915 732 loadpalset(1,1);
31916 732 loadpalset(5,5);
31917
31918
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 12 times.
732 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
31919 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
31920 732 }
31921 2928 }
31922 else
31923 {
31924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1872 if(!flash_reduction_enabled() && (f&7) == 0)
31925 {
31926 for(int32_t cs2=2; cs2<5; cs2++)
31927 {
31928 for(int32_t i=1; i<16; i++)
31929 {
31930 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
31931 }
31932 }
31933
31934 refreshpal=true;
31935 }
31936
31937
2/2
✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 234 times.
1872 if((f&7)==4)
31938 {
31939
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
31940 else loadlvlpal(0xB);
31941
31942 234 loadpalset(5,5);
31943 234 }
31944 }
31945 4800 }
31946
31947
31948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_gamedata)
31949 {
31950
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==refill_frame)
31951 {
31952 100 refill_what=REFILL_ALL;
31953 100 refill_why=id2;
31954 100 StartRefill(REFILL_ALL);
31955 100 refill();
31956 100 }
31957
31958
2/2
✓ Branch 0 taken 47900 times.
✓ Branch 1 taken 4460 times.
52360 if(f==(refill_frame+1))
31959 {
31960
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4360 times.
4460 if(refill())
31961 {
31962 4360 --f;
31963 4360 }
31964 4460 }
31965 52360 }
31966
31967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_flag1) // Warp out flag
31968 {
31969
4/4
✓ Branch 0 taken 27200 times.
✓ Branch 1 taken 25160 times.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 8000 times.
52360 if(f>=208 && f<288)
31970 {
31971 8000 ++x2;
31972
31973
3/3
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1600 times.
8000 switch(++c)
31974 {
31975 case 5:
31976 1600 c=0;
31977 [[fallthrough]];
31978 case 0:
31979 case 2:
31980 case 3:
31981 4800 ++x2;
31982 4800 break;
31983 }
31984 8000 }
31985
31986 52360 do_dcounters();
31987
31988
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 33160 times.
52360 if(f<288)
31989 {
31990 33160 curtain_x=TRUNCATE_HALF_TILE(x2);
31991 33160 draw_screen_clip_rect_x1=curtain_x;
31992 33160 draw_screen_clip_rect_x2=255-curtain_x;
31993 33160 draw_screen_clip_rect_y1=0;
31994 33160 draw_screen_clip_rect_y2=231;
31995 33160 }
31996 52360 }
31997
31998 52360 draw_screen();
31999
32000 //Run Triforce Script
32001 52360 advanceframe(true);
32002 52360 ++f;
32003
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
104720 }
32004 while
32005 (
32006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
32007
4/6
✓ Branch 0 taken 7300 times.
✓ Branch 1 taken 45060 times.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
52360 || (!(itemsbuf[id2].flags & item_flag15) /*&& !(itemsbuf[id2].flags & item_flag11)*/ && (midi_pos > 0 && !replay_is_active()))
32008
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14600 || (/*!(itemsbuf[id2].flags & item_flag15) &&*/ !(itemsbuf[id2].flags & item_flag11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
32009 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
32010 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
32011 // value doesn't matter.
32012
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7300 times.
7300 || (replay_is_active() && f < 480) )
32013 ); // 800 may not be just right, but it works
32014
32015 100 action=none; FFCore.setHeroAction(none);
32016 100 holdclk=0;
32017 100 draw_screen_clip_rect_x1=0;
32018 100 draw_screen_clip_rect_x2=255;
32019 100 draw_screen_clip_rect_y1=0;
32020 100 draw_screen_clip_rect_y2=231;
32021 100 show_subscreen_items=true;
32022
32023 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
32024 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
32025
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 1 times.
100 if((itemsbuf[id2].flags & item_flag1) && ( get_qr(qr_SIDEVIEWTRIFORCECELLAR) ? ( cur_screen < MAPSCRS192b136 ) : (cur_screen < MAPSCRSNORMAL) ) )
32026 {
32027 99 sdir=dir;
32028 99 dowarp(hero_scr, 1, 0); //side warp
32029 99 }
32030 else
32031 {
32032
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( !(itemsbuf[id2].flags & item_flag11) ) playLevelMusic();
32033 }
32034 100 }
32035
32036 29289 void red_shift()
32037 {
32038 29289 int32_t tnum=176;
32039
32040 // set up the new palette
32041
2/2
✓ Branch 0 taken 937248 times.
✓ Branch 1 taken 29289 times.
966537 for(int32_t i=CSET(2); i < CSET(4); i++)
32042 {
32043 937248 int32_t r = (i-CSET(2)) << 1;
32044 937248 RAMpal[i+tnum].r = _rgb_scale_6[r];
32045 937248 RAMpal[i+tnum].g = _rgb_scale_6[r >> 3];
32046 937248 RAMpal[i+tnum].b = _rgb_scale_6[r >> 4];
32047 937248 }
32048
32049 // color scale the game screen
32050
2/2
✓ Branch 0 taken 4922328 times.
✓ Branch 1 taken 29289 times.
4951617 for(int32_t y=0; y<viewport.visible_height(show_bottom_8px); y++)
32051 {
32052
2/2
✓ Branch 0 taken 1260115968 times.
✓ Branch 1 taken 4922328 times.
1265038296 for(int32_t x=0; x<framebuf->w; x++)
32053 {
32054 1260115968 int c = framebuf->line[y+original_playing_field_offset][x];
32055 1260115968 int r = RAMpal[c].r / 4;
32056 1260115968 int g = RAMpal[c].g / 4;
32057 1260115968 int b = RAMpal[c].b / 4;
32058
2/2
✓ Branch 0 taken 1174976904 times.
✓ Branch 1 taken 85139064 times.
1260115968 int v = zc_min(int32_t(r*0.4 + g*0.6 + b*0.4)>>1,31);
32059
2/2
✓ Branch 0 taken 1259249135 times.
✓ Branch 1 taken 866833 times.
1260115968 putpixel(framebuf, x, y + original_playing_field_offset, c ? (v + tnum+CSET(2)) : 0);
32060 1260115968 }
32061 4922328 }
32062
32063 29289 refreshpal = true;
32064 29289 }
32065
32066 75 void slide_in_color(int32_t color)
32067 {
32068
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 75 times.
450 for(int32_t i=1; i<16; i+=3)
32069 {
32070 375 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
32071 375 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
32072 375 RAMpal[CSET(2)+i] = NESpal(color);
32073 375 }
32074
32075 75 refreshpal=true;
32076 75 }
32077
32078
32079 282 void HeroClass::heroDeathAnimation()
32080 {
32081 282 int32_t f=0;
32082 282 int32_t deathclk=0,deathfrm=0;
32083
32084 282 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
32085
32086 282 kill_sfx(); //call before the onDeath script.
32087
32088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(!debug_enabled)
32089 {
32090 282 Paused=false;
32091 282 }
32092
32093 282 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
32094 282 clear_bitmap(subscrbmp);
32095 //get rid off all sprites but Hero
32096 282 guys.clear();
32097 282 items.clear();
32098 282 Ewpns.clear();
32099 282 Lwpns.clear();
32100 282 chainlinks.clear();
32101 282 decorations.clear();
32102
32103 282 kill_subscr_items();
32104
32105 282 Playing = false;
32106
32107
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
32108 282 dir=down;
32109 282 music_stop();
32110
32111 282 attackclk=hclk=superman=0;
32112 282 scriptcoldet = true;
32113
32114
2/2
✓ Branch 0 taken 9024 times.
✓ Branch 1 taken 282 times.
9306 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
32115
32116
32117 282 playing_field_offset = original_playing_field_offset; // otherwise, red_shift() may go past the bottom of the screen
32118 282 quakeclk=wavy=0;
32119
32120 //in original Z1, Hero marker vanishes at death.
32121 //code in subscr.cpp, put_passive_subscr checks the following value.
32122 //color 255 is a GUI color, so quest makers shouldn't be using this value.
32123 //Also, subscreen is static after death in Z1.
32124 282 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
32125 282 QMisc.colors.hero_dot = 255;
32126
32127 282 put_passive_subscr(subscrbmp, 0, 0, game->should_show_time(), sspUP);
32128 //Don't forget passive subscreen scripts!
32129
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 24 times.
282 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
32130 {
32131 24 script_drawing_commands.Clear(); //We only want draws from this script
32132
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(DMaps[cur_dmap].passive_sub_script != 0)
32133 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
32134
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[cur_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
32135 {
32136 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
32137 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
32138 }
32139 24 BITMAP* tmp = framebuf;
32140 24 framebuf = subscrbmp; //Hack; force draws to subscrbmp
32141 24 do_script_draws(framebuf, origin_scr, 0, playing_field_offset); //Draw the script draws
32142 24 framebuf = tmp;
32143 24 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
32144 24 }
32145 282 QMisc.colors.hero_dot = tmp_hero_dot;
32146 282 bool clearedit = false;
32147 282 do
32148 {
32149
2/2
✓ Branch 0 taken 71105 times.
✓ Branch 1 taken 25856 times.
96961 if(f<254)
32150 {
32151
2/2
✓ Branch 0 taken 61863 times.
✓ Branch 1 taken 9242 times.
71105 if(f<=32)
32152 {
32153 9242 hclk=(32-f);
32154 9242 }
32155
32156
4/4
✓ Branch 0 taken 53743 times.
✓ Branch 1 taken 17362 times.
✓ Branch 2 taken 32525 times.
✓ Branch 3 taken 21218 times.
71105 if(f>=62 && f<138)
32157 {
32158
5/5
✓ Branch 0 taken 16751 times.
✓ Branch 1 taken 1117 times.
✓ Branch 2 taken 1117 times.
✓ Branch 3 taken 1117 times.
✓ Branch 4 taken 1116 times.
21218 switch((f-62)%20)
32159 {
32160 case 0:
32161 1117 dir=right;
32162 1117 break;
32163
32164 case 5:
32165 1117 dir=up;
32166 1117 break;
32167
32168 case 10:
32169 1117 dir=left;
32170 1117 break;
32171
32172 case 15:
32173 1116 dir=down;
32174 1116 break;
32175 }
32176
32177 21218 herostep();
32178 21218 }
32179
32180
4/4
✓ Branch 0 taken 16957 times.
✓ Branch 1 taken 54148 times.
✓ Branch 2 taken 12766 times.
✓ Branch 3 taken 4191 times.
71105 if(f>=194 && f<208)
32181 {
32182
2/2
✓ Branch 0 taken 3913 times.
✓ Branch 1 taken 278 times.
4191 if(f==194)
32183 {
32184 278 action=dying;
32185 278 FFCore.setHeroAction(dying);
32186 278 }
32187
32188 4191 extend = 0;
32189 4191 cs = wpnsbuf[spr_death].csets&15;
32190 4191 tile = wpnsbuf[spr_death].tile;
32191
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 607 times.
4191 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
32192 {
32193 607 tile += deathfrm;
32194 607 f = 206;
32195
2/2
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 88 times.
607 if(++deathclk >= wpnsbuf[spr_death].speed)
32196 {
32197 88 deathclk=0;
32198
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 if(++deathfrm >= wpnsbuf[spr_death].frames)
32199 {
32200 22 f = 208;
32201 22 deathfrm = 0;
32202 22 }
32203 88 }
32204 607 }
32205
2/2
✓ Branch 0 taken 2702 times.
✓ Branch 1 taken 882 times.
3584 else if(BSZ)
32206 {
32207 2702 tile += (f-194)/3;
32208 2702 }
32209
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 252 times.
882 else if(f>=204)
32210 {
32211 252 ++tile;
32212 252 }
32213 4191 }
32214
32215
2/2
✓ Branch 0 taken 70827 times.
✓ Branch 1 taken 278 times.
71105 if(f==208)
32216 {
32217
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 274 times.
278 if ( dontdraw < 2 ) { dontdraw = 1; }
32218 278 }
32219
2/2
✓ Branch 0 taken 67295 times.
✓ Branch 1 taken 3810 times.
71105 if(get_qr(qr_FADE))
32220 {
32221
2/2
✓ Branch 0 taken 44926 times.
✓ Branch 1 taken 22369 times.
67295 if(f < 170)
32222 {
32223
2/2
✓ Branch 0 taken 29024 times.
✓ Branch 1 taken 15902 times.
44926 if(f<60)
32224 {
32225 15902 draw_screen();
32226 //reuse our static subscreen
32227 15902 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
32228 15902 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32229 15902 }
32230
32231
2/2
✓ Branch 0 taken 44661 times.
✓ Branch 1 taken 265 times.
44926 if(f==60)
32232 {
32233 265 red_shift();
32234 265 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
32235 265 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
32236 265 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
32237
32238
2/2
✓ Branch 0 taken 67840 times.
✓ Branch 1 taken 265 times.
68105 for(int32_t q=0; q<PAL_SIZE; q++)
32239 {
32240 67840 trans_table2.data[0][q] = q;
32241 67840 trans_table2.data[q][q] = q;
32242 67840 }
32243 265 }
32244
32245
3/4
✓ Branch 0 taken 29024 times.
✓ Branch 1 taken 15902 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29024 times.
44926 if(f>=60 && f<=169)
32246 {
32247 29024 draw_screen();
32248 //reuse our static subscreen
32249 29024 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32250 29024 red_shift();
32251
32252 29024 }
32253
32254
3/4
✓ Branch 0 taken 8153 times.
✓ Branch 1 taken 36773 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8153 times.
44926 if(f>=139 && f<=169)//fade from red to black
32255 {
32256 8153 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
32257 8153 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
32258 8153 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
32259 8153 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
32260
32261
2/2
✓ Branch 0 taken 2087168 times.
✓ Branch 1 taken 8153 times.
2095321 for(int32_t q=0; q<PAL_SIZE; q++)
32262 {
32263 2087168 trans_table2.data[0][q] = q;
32264 2087168 trans_table2.data[q][q] = q;
32265 2087168 }
32266
32267 8153 refreshpal=true;
32268 8153 }
32269 44926 }
32270 else //f>=170
32271 {
32272
2/2
✓ Branch 0 taken 22106 times.
✓ Branch 1 taken 263 times.
22369 if(f==170)//make Hero grayish
32273 {
32274 263 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
32275
32276
2/2
✓ Branch 0 taken 4208 times.
✓ Branch 1 taken 263 times.
4471 for(int32_t i=CSET(6); i < CSET(7); i++)
32277 {
32278 4208 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
32279 4208 RAMpal[i] = _RGB(g,g,g);
32280 4208 }
32281
32282 263 refreshpal = true;
32283 263 }
32284
32285 //draw only hero. otherwise black layers might cover him.
32286 22369 rectfill(framebuf,0,original_playing_field_offset,framebuf->w,framebuf->h,0);
32287 22369 draw(framebuf);
32288 22369 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32289 }
32290 67295 }
32291 else //!qr_FADE
32292 {
32293 7620 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
32294
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==58)
32295 {
32296
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 15 times.
1455 for(int32_t i = 0; i < 96; i++)
32297 1440 scr->cset[i] = 3;
32298
32299
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32300
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32301 {
32302 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32303
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
32304 192 lyr_scr->cset[i] = 3;
32305 2 }
32306 15 }
32307
32308
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==59)
32309 {
32310
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 15 times.
1215 for(int32_t i = 96; i < 176; i++)
32311 1200 scr->cset[i] = 3;
32312
32313
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32314
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32315 {
32316 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32317
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
32318 160 lyr_scr->cset[i] = 3;
32319 2 }
32320 15 }
32321
32322
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
32323 {
32324
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 15 times.
2655 for(int32_t i=0; i<176; i++)
32325 {
32326 2640 scr->cset[i] = 2;
32327 2640 }
32328
32329
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32330
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32331 {
32332 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32333
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
32334 352 lyr_scr->cset[i] = 2;
32335 2 }
32336 15 }
32337 3810 });
32338
32339
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
32340 {
32341
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
32342 {
32343 75 RAMpal[CSET(2)+i] = NESpal(0x17);
32344 75 RAMpal[CSET(2)+i+1] = NESpal(0x16);
32345 75 RAMpal[CSET(2)+i+2] = NESpal(0x26);
32346 75 }
32347
32348 15 refreshpal=true;
32349 15 }
32350
32351
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==139)
32352 15 slide_in_color(0x06);
32353
32354
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==149)
32355 15 slide_in_color(0x07);
32356
32357
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==159)
32358 15 slide_in_color(0x0F);
32359
32360
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==169)
32361 {
32362 15 slide_in_color(0x0F);
32363 15 slide_in_color(0x0F);
32364 15 }
32365
32366
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==170)
32367 {
32368
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
32369 {
32370 75 RAMpal[CSET(6)+i] = NESpal(0x10);
32371 75 RAMpal[CSET(6)+i+1] = NESpal(0x30);
32372 75 RAMpal[CSET(6)+i+2] = NESpal(0x00);
32373 75 refreshpal = true;
32374 75 }
32375 15 }
32376
32377
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 1275 times.
3810 if(f < 169)
32378 {
32379 2535 draw_screen();
32380 //reuse our static subscreen
32381 2535 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32382 2535 }
32383 else
32384 {
32385 //draw only hero. otherwise black layers might cover him.
32386 1275 rectfill(framebuf,0,playing_field_offset,framebuf->w,framebuf->h,0);
32387 1275 draw(framebuf);
32388 1275 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32389 }
32390 }
32391 71105 }
32392
32393
2/2
✓ Branch 0 taken 25073 times.
✓ Branch 1 taken 783 times.
25856 else if(f<350)//draw 'GAME OVER' text
32394 {
32395
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 25071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
25073 if(get_qr(qr_INSTANT_RESPAWN) && !get_qr(qr_INSTANT_CONTINUE))
32396 {
32397 2 Quit = qRELOAD;
32398 2 skipcont = 1;
32399 2 clear_bitmap(framebuf);
32400 2 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32401 2 }
32402
3/4
✓ Branch 0 taken 25071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25056 times.
✓ Branch 3 taken 15 times.
25071 else if(!get_qr(qr_INSTANT_RESPAWN) && get_qr(qr_INSTANT_CONTINUE))
32403 {
32404 15 Quit = qCONT;
32405 15 skipcont = 1;
32406 15 clear_bitmap(framebuf);
32407 15 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32408 15 }
32409 else
32410 {
32411 25056 clear_info_bmp();
32412 25056 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
32413 25056 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32414 25056 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
32415 }
32416 25073 }
32417 else
32418 {
32419 783 clear_bitmap(framebuf);
32420 }
32421
32422 //SFX... put them all here
32423
4/4
✓ Branch 0 taken 96143 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 256 times.
96961 switch(f)
32424 {
32425 case 0:
32426 282 sfx(getHurtSFX(),pan(x.getInt()));
32427 282 break;
32428 //Death sound.
32429 case 60:
32430 280 sfx(WAV_SPIRAL);
32431 280 break;
32432 //Message sound.
32433 case 194:
32434 256 sfx(WAV_MSG);
32435 256 break;
32436 }
32437 //adv:
32438 96961 clear_darkroom_bitmaps();
32439 96961 advanceframe(true);
32440 96961 ++f;
32441
2/2
✓ Branch 0 taken 96679 times.
✓ Branch 1 taken 282 times.
193922 }
32442
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 96700 times.
96961 while(f<353 && !Quit);
32443
32444 282 destroy_bitmap(subscrbmp);
32445 282 action=none; FFCore.setHeroAction(none);
32446
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 278 times.
282 if ( dontdraw < 2 ) { dontdraw=0; }
32447 282 }
32448
32449 17 void HeroClass::ganon_intro()
32450 {
32451 17 mapscr* scr = hero_scr;
32452 17 int screen = scr->screen;
32453 77 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
32454
32455 /*
32456 ************************
32457 * GANON INTRO SEQUENCE *
32458 ************************
32459 -25 DOT updates
32460 -24 HERO in
32461 0 TRIFORCE overhead - code begins at this point (f == 0)
32462 47 GANON in
32463 58 LIGHT step
32464 68 LIGHT step
32465 78 LIGHT step
32466 255 TRIFORCE out
32467 256 TRIFORCE in
32468 270 TRIFORCE out
32469 271 GANON out, HERO face up
32470 */
32471 17 loaded_guys=true;
32472 51 loaditem(scr, offx, offy);
32473
32474
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13 times.
17 if(game->lvlitems[dlevel]&liBOSS)
32475 {
32476 4 return;
32477 }
32478
32479 13 dir=down;
32480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( !isSideViewHero() )
32481 {
32482 13 fall = 0; //Fix midair glitch on holding triforce. -Z
32483 13 fakefall = 0;
32484 13 z = 0;
32485 13 fakez = 0;
32486 13 }
32487 13 action=landhold2; FFCore.setHeroAction(landhold2);
32488 13 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
32489 //not good, as this only returns the highest level that Hero possesses. -DD
32490 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
32491
32492
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3133 times.
✓ Branch 2 taken 3133 times.
✓ Branch 3 taken 13 times.
3146 for(int32_t f=0; f<271 && !Quit; f++)
32493 {
32494
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==47)
32495 {
32496 13 music_stop();
32497 13 stop_sfx(WAV_ROAR);
32498 13 sfx(WAV_GASP);
32499 13 sfx(WAV_GANON);
32500 13 int32_t Id=0;
32501
32502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 for(int32_t i=0; i<eMAXGUYS; i++)
32503 {
32504
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 13 times.
1027 if(guysbuf[i].flags&guy_ganon)
32505 {
32506 13 Id=i;
32507 13 break;
32508 }
32509 1014 }
32510
32511
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 if(current_item(itype_ring))
32512 {
32513 30 addenemy(screen,offx+160,offy+96,Id,0);
32514 10 }
32515 else
32516 {
32517 9 addenemy(screen,offx+80,offy+32,Id,0);
32518 }
32519 13 }
32520
32521
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==48)
32522 {
32523 13 lighting(true,true); // Hmm. -L
32524 13 f += 30;
32525 13 }
32526
32527 //NES Z1, the triforce vanishes for one frame in two cases
32528 //while still showing Hero's two-handed overhead sprite.
32529 //This should be a Quest Rule for NES Accuracy. -Z
32530
4/4
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 3107 times.
3133 if(f==255 || f==270)
32531 {
32532 26 holditem=-1;
32533 26 }
32534
32535
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==256)
32536 {
32537 13 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
32538 13 }
32539
32540 3133 draw_screen();
32541 3133 advanceframe(true);
32542
32543
1/2
✓ Branch 0 taken 3133 times.
✗ Branch 1 not taken.
3133 if(rSbtn())
32544 {
32545 conveyclk=3;
32546 int32_t tmp_subscr_clk = frame;
32547 dosubscr();
32548 newscr_clk += frame - tmp_subscr_clk;
32549 }
32550
32551 3133 }
32552
32553 13 action=none; FFCore.setHeroAction(none);
32554 13 dir=up;
32555
32556
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
13 if((!getmapflag(screen, mSPECIALITEM) || (scr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
32557 2 jukebox(MAXMIDIS-1);
32558 else
32559 11 playLevelMusic();
32560
32561 13 currcset=DMaps[cur_dmap].color;
32562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (get_qr(qr_GANONINTRO) )
32563 {
32564 13 dointro();
32565 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
32566 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
32567 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
32568 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
32569 13 }
32570
32571 13 cont_sfx(WAV_ROAR);
32572 17 }
32573
32574 10 void HeroClass::win_game()
32575 {
32576
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 replay_step_comment("win_game");
32577 10 Playing=Paused=false;
32578 10 action=won; FFCore.setHeroAction(won);
32579 10 Quit=qWON;
32580 10 hclk=0;
32581 10 x = 136;
32582
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 y = (isdungeon() && cur_screen<128) ? 75 : 73;
32583 10 z = fakez = fall = fakefall = spins = 0;
32584 10 dir=left;
32585 10 }
32586
32587 40077 void HeroClass::reset_swordcharge()
32588 {
32589 40077 charging=spins=tapping=0;
32590 40077 }
32591
32592 142622 void HeroClass::reset_hookshot()
32593 {
32594
10/12
✓ Branch 0 taken 91846 times.
✓ Branch 1 taken 50776 times.
✓ Branch 2 taken 91832 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 91730 times.
✓ Branch 5 taken 102 times.
✓ Branch 6 taken 91723 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 91723 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 91723 times.
142622 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
32595 {
32596 91723 action=none; FFCore.setHeroAction(none);
32597 91723 }
32598
32599 142622 hookshot_frozen=false;
32600 142622 hookshot_used=false;
32601 142622 pull_hero=false;
32602 142622 hs_fix=false;
32603 142622 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
32604 142622 switch_hooked = false;
32605
2/2
✓ Branch 0 taken 142617 times.
✓ Branch 1 taken 5 times.
142622 if(switching_object)
32606 5 switching_object->switch_hooked = false;
32607 142622 switching_object = NULL;
32608 142622 hooked_comborpos = rpos_t::None;
32609 142622 switchhook_cost_item = -1;
32610 142622 hooked_layerbits = 0;
32611
2/2
✓ Branch 0 taken 998354 times.
✓ Branch 1 taken 142622 times.
1140976 for(auto q = 0; q < 7; ++q)
32612 998354 hooked_undercombos[q] = -1;
32613 142622 Lwpns.del(Lwpns.idFirst(wHSHandle));
32614 142622 Lwpns.del(Lwpns.idFirst(wHookshot));
32615 142622 chainlinks.clear();
32616
2/2
✓ Branch 0 taken 35856 times.
✓ Branch 1 taken 106766 times.
142622 int32_t index=directWpn>-1 ? directWpn : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
32617 142622 hs_switcher = false;
32618
32619
2/2
✓ Branch 0 taken 96542 times.
✓ Branch 1 taken 46080 times.
142622 if(index>=0)
32620 {
32621 46080 stop_sfx(itemsbuf[index].usesound);
32622 46080 }
32623
32624 142622 hs_xdist=0;
32625 142622 hs_ydist=0;
32626 142622 }
32627
32628
32629 17256590 bool HeroClass::can_deploy_ladder()
32630 {
32631
2/2
✓ Branch 0 taken 7099759 times.
✓ Branch 1 taken 10156831 times.
30496304 bool ladderallowed = ((!get_qr(qr_LADDERANYWHERE) && (hero_scr->flags&fLADDER)) || isdungeon()
32632
4/4
✓ Branch 0 taken 3924797 times.
✓ Branch 1 taken 13239714 times.
✓ Branch 2 taken 4778804 times.
✓ Branch 3 taken 8460910 times.
10156831 || (get_qr(qr_LADDERANYWHERE) && !(hero_scr->flags&fLADDER)));
32633
9/10
✓ Branch 0 taken 6746780 times.
✓ Branch 1 taken 17517490 times.
✓ Branch 2 taken 3086745 times.
✓ Branch 3 taken 3660035 times.
✓ Branch 4 taken 3086449 times.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 3085744 times.
✓ Branch 7 taken 705 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3085744 times.
27350014 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
32634
2/2
✓ Branch 0 taken 3064933 times.
✓ Branch 1 taken 20811 times.
3085744 (!isSideViewHero() || on_sideview_solid_oldpos(this)));
32635 }
32636
32637 9611690 void HeroClass::reset_ladder()
32638 {
32639 9611690 ladderx=laddery=0;
32640 9611690 }
32641
32642 bool is_conveyor(int32_t type);
32643 int32_t get_conveyor(int32_t x, int32_t y);
32644
32645 14328342 void HeroClass::check_conveyor()
32646 {
32647 14328342 ++newconveyorclk;
32648
32649
2/2
✓ Branch 0 taken 14324966 times.
✓ Branch 1 taken 3376 times.
14328342 if (is_conveyor_stunned > 0)
32650 3376 --is_conveyor_stunned;
32651
2/2
✓ Branch 0 taken 14324662 times.
✓ Branch 1 taken 3680 times.
14328342 if (is_on_conveyor > 0)
32652 {
32653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3680 times.
3680 if(!--is_on_conveyor)
32654 3680 conv_forcedir = -1;
32655 3680 }
32656
32657
14/16
✓ Branch 0 taken 11194 times.
✓ Branch 1 taken 14317148 times.
✓ Branch 2 taken 14303875 times.
✓ Branch 3 taken 13273 times.
✓ Branch 4 taken 14303875 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14297763 times.
✓ Branch 7 taken 6112 times.
✓ Branch 8 taken 14297763 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14297507 times.
✓ Branch 11 taken 256 times.
✓ Branch 12 taken 14290212 times.
✓ Branch 13 taken 7295 times.
✓ Branch 14 taken 17183 times.
✓ Branch 15 taken 14273029 times.
14328342 if((!get_qr(qr_BROKEN_CONVEYORS) && action==rafting) || action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero)
32658 {
32659 55313 is_conveyor_stunned = 0;
32660 55313 return;
32661 }
32662
32663 14273029 WalkflagInfo info;
32664 int32_t xoff,yoff;
32665 14273029 zfix deltax(0), deltay(0);
32666 14273029 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
32667
2/2
✓ Branch 0 taken 19479 times.
✓ Branch 1 taken 14253550 times.
14273029 if(cmbid < 0)
32668 {
32669
2/2
✓ Branch 0 taken 9523834 times.
✓ Branch 1 taken 4729716 times.
14253550 if (conveyclk <= 0)
32670 {
32671
2/2
✓ Branch 0 taken 4728777 times.
✓ Branch 1 taken 939 times.
4729716 if(is_on_conveyor < 0)
32672 {
32673 939 is_on_conveyor = 0;
32674 939 conv_forcedir = -1;
32675 939 is_conveyor_stunned = 0;
32676 939 }
32677 4729716 }
32678 14253550 return;
32679 }
32680 19479 newcombo const* cmb = &combobuf[cmbid];
32681 19479 rpos_t rpos = COMBOPOS_REGION(x+7,y+(bigHitbox?8:12));
32682 19479 bool custom_spd = (cmb->usrflags&cflag2);
32683
6/6
✓ Branch 0 taken 19324 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 19324 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 17 times.
19479 if((z>0||fakez>0) && !((hero_scr->flags2&fAIRCOMBOS)||(cmb->usrflags&cflag7)))
32684 {
32685 17 is_on_conveyor = 0;
32686 17 conv_forcedir = -1;
32687 17 is_conveyor_stunned = 0;
32688 17 return;
32689 }
32690
3/4
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 15782 times.
✗ Branch 3 not taken.
19462 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
32691 {
32692 19462 int32_t ctype=cmb->type;
32693
4/4
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 3430 times.
19462 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32694
3/4
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3680 times.
✗ Branch 3 not taken.
19462 if(custom_spd && (newconveyorclk % rate)) return;
32695
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 16191 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19462 if((cmb->usrflags&cflag5) && HasHeavyBoots())
32696 return;
32697 19462 is_on_conveyor = 0;
32698 19462 conv_forcedir = -1;
32699 19462 is_conveyor_stunned = 0;
32700
32701 19462 deltax=combo_class_buf[ctype].conveyor_x_speed;
32702 19462 deltay=combo_class_buf[ctype].conveyor_y_speed;
32703
32704
3/4
✓ Branch 0 taken 19462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15782 times.
✓ Branch 3 taken 3680 times.
19462 if (is_conveyor(ctype) && custom_spd)
32705 {
32706 3680 deltax = zslongToFix(cmb->attributes[0]);
32707 3680 deltay = zslongToFix(cmb->attributes[1]);
32708 3680 }
32709
32710
3/8
✓ Branch 0 taken 8832 times.
✓ Branch 1 taken 10630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
19462 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(this)))
32711 {
32712 cmbid = MAPCOMBO(x+8,y+16);
32713 cmb = &combobuf[cmbid];
32714 custom_spd = cmb->usrflags&cflag2;
32715 ctype=(cmb->type);
32716 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
32717 deltax=combo_class_buf[ctype].conveyor_x_speed;
32718 deltay=combo_class_buf[ctype].conveyor_y_speed;
32719 if ((deltax != 0 || deltay != 0) && custom_spd)
32720 {
32721 deltax = zslongToFix(cmb->attributes[0]);
32722 deltay = zslongToFix(cmb->attributes[1]);
32723 }
32724 }
32725
32726
3/4
✓ Branch 0 taken 8832 times.
✓ Branch 1 taken 10630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8832 times.
19462 if(deltax!=0||deltay!=0)
32727 {
32728
2/2
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
19462 is_on_conveyor = custom_spd ? rate : -1;
32729 19462 }
32730 else return;
32731
32732
2/2
✓ Branch 0 taken 19303 times.
✓ Branch 1 taken 159 times.
19462 bool forcewalk = (cmb->usrflags&cflag6) && get_qr(qr_NEW_HERO_MOVEMENT2);
32733
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 19303 times.
19462 if(forcewalk)
32734 {
32735 159 is_conveyor_stunned = rate;
32736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if(cmb->usrflags&cflag3)
32737 {
32738
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 50 times.
159 if(abs(deltax) > abs(deltay))
32739 109 conv_forcedir = dir = (deltax > 0) ? right : left;
32740 50 else conv_forcedir = dir = (deltay > 0) ? down : up;
32741 159 }
32742 159 convey_forcex = deltax;
32743 159 convey_forcey = deltay;
32744 159 }
32745 else
32746 {
32747 19303 bool movedx = false, movedy = false;
32748
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3521 times.
19303 if(cmb->usrflags&cflag4) //Smart corners
32749 {
32750
2/2
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 2372 times.
3521 if(deltay<0)
32751 {
32752 1149 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32753 1149 execute(info);
32754
32755
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1098 times.
1149 if(!info.isUnwalkable())
32756 {
32757 1098 movedy = true;
32758 1098 zfix step(0);
32759
32760
7/12
✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 924 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1098 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32761 {
32762 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
32763 {
32764 yoff=int32_t(y-step)&7;
32765
32766 if(!yoff) break;
32767
32768 step++;
32769 }
32770 }
32771 else
32772 {
32773 1098 step=abs(deltay);
32774 }
32775
32776 1098 y=y-step;
32777 1098 hs_starty-=step.getInt();
32778
32779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1098 times.
1098 for(int32_t j=0; j<chainlinks.Count(); j++)
32780 {
32781 chainlinks.spr(j)->y-=step;
32782 }
32783
32784
1/2
✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
1098 if(Lwpns.idFirst(wHookshot)>-1)
32785 {
32786 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
32787 }
32788
32789
1/2
✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
1098 if(Lwpns.idFirst(wHSHandle)>-1)
32790 {
32791 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
32792 }
32793 1098 }
32794 1149 }
32795
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 427 times.
2372 else if(deltay>0)
32796 {
32797 427 info = walkflag(x,y+15+2,2,down);
32798 427 execute(info);
32799
32800
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 422 times.
427 if(!info.isUnwalkable())
32801 {
32802 422 movedy = true;
32803 422 zfix step(0);
32804
32805
7/12
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 311 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 102 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
422 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32806 {
32807 while(step<abs(deltay))
32808 {
32809 yoff=int32_t(y+step)&7;
32810
32811 if(!yoff) break;
32812
32813 step++;
32814 }
32815 }
32816 else
32817 {
32818 422 step=abs(deltay);
32819 }
32820
32821 422 y=y+step;
32822 422 hs_starty+=step.getInt();
32823
32824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
422 for(int32_t j=0; j<chainlinks.Count(); j++)
32825 {
32826 chainlinks.spr(j)->y+=step;
32827 }
32828
32829
1/2
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
422 if(Lwpns.idFirst(wHookshot)>-1)
32830 {
32831 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
32832 }
32833
32834
1/2
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
422 if(Lwpns.idFirst(wHSHandle)>-1)
32835 {
32836 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
32837 }
32838 422 }
32839 427 }
32840
32841
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 2989 times.
3521 if(deltax<0)
32842 {
32843 532 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
32844 532 execute(info);
32845
32846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!info.isUnwalkable())
32847 {
32848 532 movedx = true;
32849 532 zfix step(0);
32850
32851
7/12
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 522 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
532 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32852 {
32853 while(step<abs(deltax))
32854 {
32855 xoff=int32_t(x-step)&7;
32856
32857 if(!xoff) break;
32858
32859 step++;
32860 }
32861 }
32862 else
32863 {
32864 532 step=abs(deltax);
32865 }
32866
32867 532 x=x-step;
32868 532 hs_startx-=step.getInt();
32869
32870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 for(int32_t j=0; j<chainlinks.Count(); j++)
32871 {
32872 chainlinks.spr(j)->x-=step;
32873 }
32874
32875
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(Lwpns.idFirst(wHookshot)>-1)
32876 {
32877 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
32878 }
32879
32880
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(Lwpns.idFirst(wHSHandle)>-1)
32881 {
32882 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
32883 }
32884 532 }
32885 532 }
32886
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 1413 times.
2989 else if(deltax>0)
32887 {
32888 1413 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
32889 1413 execute(info);
32890
32891
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1399 times.
1413 if(!info.isUnwalkable())
32892 {
32893 1399 movedx = true;
32894 1399 zfix step(0);
32895
32896
7/12
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 1184 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 168 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1399 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
32897 {
32898 while(step<abs(deltax))
32899 {
32900 xoff=int32_t(x+step)&7;
32901
32902 if(!xoff) break;
32903
32904 step++;
32905 }
32906 }
32907 else
32908 {
32909 1399 step=abs(deltax);
32910 }
32911
32912 1399 x=x+step;
32913 1399 hs_startx+=step.getInt();
32914
32915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1399 times.
1399 for(int32_t j=0; j<chainlinks.Count(); j++)
32916 {
32917 chainlinks.spr(j)->x+=step;
32918 }
32919
32920
1/2
✓ Branch 0 taken 1399 times.
✗ Branch 1 not taken.
1399 if(Lwpns.idFirst(wHookshot)>-1)
32921 {
32922 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
32923 }
32924
32925
1/2
✓ Branch 0 taken 1399 times.
✗ Branch 1 not taken.
1399 if(Lwpns.idFirst(wHSHandle)>-1)
32926 {
32927 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
32928 }
32929 1399 }
32930 1413 }
32931
5/6
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 1576 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1931 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
3521 if(deltax && !movedx && !deltay)
32932 {
32933 14 zfix oy = y;
32934 14 y = COMBOY_REGION(rpos);
32935 14 bool validpush = scr_canmove(deltax, 0, false, false);
32936
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
28 zfix ny = handle_movestate_zfix([&]()
32937 {
32938 14 movexy(deltax,0,false,false,true,true);
32939 14 return y;
32940 });
32941 14 y = oy;
32942
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if (validpush || ny != COMBOY_REGION(rpos))
32943 {
32944
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (y <= ny-1)
32945 {
32946 14 setYfix(y+1);
32947 14 }
32948 else if (y >= ny+1)
32949 {
32950 setYfix(y-1);
32951 }
32952 else
32953 {
32954 setYfix(ny);
32955 }
32956 14 }
32957 14 }
32958
5/6
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 1945 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 1520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
3521 if(deltay && !movedy && !deltax)
32959 {
32960 56 zfix ox = x;
32961 56 x = COMBOX_REGION(rpos);
32962 56 bool validpush = scr_canmove(0, deltay, false, false);
32963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
112 zfix nx = handle_movestate_zfix([&]()
32964 {
32965 56 movexy(0,deltay,false,false,true,true);
32966 56 return x;
32967 });
32968 56 x = ox;
32969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56 if (validpush || nx != COMBOX_REGION(rpos))
32970 {
32971
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3 times.
56 if (x <= nx-1)
32972 {
32973 53 setXfix(x+1);
32974 53 }
32975
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (x >= nx+1)
32976 {
32977 setXfix(x-1);
32978 }
32979 else
32980 {
32981 3 setXfix(nx);
32982 }
32983 56 }
32984 56 }
32985 3521 }
32986
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 17783 times.
19303 if(!movedy)
32987 {
32988
2/2
✓ Branch 0 taken 2764 times.
✓ Branch 1 taken 15019 times.
17783 if(deltay<0)
32989 {
32990 2764 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
32991 2764 execute(info);
32992
32993
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2517 times.
2764 if(!info.isUnwalkable())
32994 {
32995 2517 movedy = true;
32996 2517 zfix step(0);
32997
32998
10/12
✓ Branch 0 taken 1942 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 703 times.
✓ Branch 3 taken 1814 times.
✓ Branch 4 taken 218 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 23 times.
✓ Branch 8 taken 195 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
2517 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
32999 {
33000
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 373 times.
530 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
33001 {
33002 373 yoff=int32_t(y-step)&7;
33003
33004
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 38 times.
373 if(!yoff) break;
33005
33006 335 step++;
33007 }
33008 195 }
33009 else
33010 {
33011 2322 step=abs(deltay);
33012 }
33013
33014 2517 y=y-step;
33015 2517 hs_starty-=step.getInt();
33016
33017
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2517 times.
2536 for(int32_t j=0; j<chainlinks.Count(); j++)
33018 {
33019 19 chainlinks.spr(j)->y-=step;
33020 19 }
33021
33022
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHookshot)>-1)
33023 {
33024 19 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
33025 19 }
33026
33027
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHSHandle)>-1)
33028 {
33029 19 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
33030 19 }
33031 2517 }
33032 247 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
33033 2764 }
33034
2/2
✓ Branch 0 taken 10521 times.
✓ Branch 1 taken 4498 times.
15019 else if(deltay>0)
33035 {
33036 4498 info = walkflag(x,y+15+2,2,down);
33037 4498 execute(info);
33038
33039
2/2
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 3601 times.
4498 if(!info.isUnwalkable())
33040 {
33041 3601 movedy = true;
33042 3601 zfix step(0);
33043
33044
10/12
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 956 times.
✓ Branch 3 taken 2645 times.
✓ Branch 4 taken 444 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 388 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 388 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 388 times.
3601 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
33045 {
33046
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 646 times.
881 while(step<abs(deltay))
33047 {
33048 646 yoff=int32_t(y+step)&7;
33049
33050
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 153 times.
646 if(!yoff) break;
33051
33052 493 step++;
33053 }
33054 388 }
33055 else
33056 {
33057 3213 step=abs(deltay);
33058 }
33059
33060 3601 y=y+step;
33061 3601 hs_starty+=step.getInt();
33062
33063
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3601 times.
3614 for(int32_t j=0; j<chainlinks.Count(); j++)
33064 {
33065 13 chainlinks.spr(j)->y+=step;
33066 13 }
33067
33068
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHookshot)>-1)
33069 {
33070 39 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
33071 39 }
33072
33073
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHSHandle)>-1)
33074 {
33075 39 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
33076 39 }
33077 3601 }
33078 897 else checkdamagecombos(x,y+15);
33079 4498 }
33080 17783 }
33081
2/2
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 17372 times.
19303 if(!movedx)
33082 {
33083
2/2
✓ Branch 0 taken 5381 times.
✓ Branch 1 taken 11991 times.
17372 if(deltax<0)
33084 {
33085 5381 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
33086 5381 execute(info);
33087
33088
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 5104 times.
5381 if(!info.isUnwalkable())
33089 {
33090 5104 movedx = true;
33091 5104 zfix step(0);
33092
33093
10/12
✓ Branch 0 taken 4579 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 4415 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 372 times.
✓ Branch 6 taken 244 times.
✓ Branch 7 taken 73 times.
✓ Branch 8 taken 244 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 244 times.
5104 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
33094 {
33095
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 456 times.
635 while(step<abs(deltax))
33096 {
33097 456 xoff=int32_t(x-step)&7;
33098
33099
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 65 times.
456 if(!xoff) break;
33100
33101 391 step++;
33102 }
33103 244 }
33104 else
33105 {
33106 4860 step=abs(deltax);
33107 }
33108
33109 5104 x=x-step;
33110 5104 hs_startx-=step.getInt();
33111
33112
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5104 times.
5146 for(int32_t j=0; j<chainlinks.Count(); j++)
33113 {
33114 42 chainlinks.spr(j)->x-=step;
33115 42 }
33116
33117
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHookshot)>-1)
33118 {
33119 51 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
33120 51 }
33121
33122
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHSHandle)>-1)
33123 {
33124 51 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
33125 51 }
33126 5104 }
33127 277 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
33128 5381 }
33129
2/2
✓ Branch 0 taken 8782 times.
✓ Branch 1 taken 3209 times.
11991 else if(deltax>0)
33130 {
33131 3209 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
33132 3209 execute(info);
33133
33134
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3127 times.
3209 if(!info.isUnwalkable())
33135 {
33136 3127 movedx = true;
33137 3127 zfix step(0);
33138
33139
10/12
✓ Branch 0 taken 2627 times.
✓ Branch 1 taken 500 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 2617 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 203 times.
✓ Branch 7 taken 106 times.
✓ Branch 8 taken 203 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 203 times.
3127 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
33140 {
33141
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 341 times.
460 while(step<abs(deltax))
33142 {
33143 341 xoff=int32_t(x+step)&7;
33144
33145
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 84 times.
341 if(!xoff) break;
33146
33147 257 step++;
33148 }
33149 203 }
33150 else
33151 {
33152 2924 step=abs(deltax);
33153 }
33154
33155 3127 x=x+step;
33156 3127 hs_startx+=step.getInt();
33157
33158
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 3127 times.
3148 for(int32_t j=0; j<chainlinks.Count(); j++)
33159 {
33160 21 chainlinks.spr(j)->x+=step;
33161 21 }
33162
33163
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHookshot)>-1)
33164 {
33165 23 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
33166 23 }
33167
33168
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHSHandle)>-1)
33169 {
33170 23 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
33171 23 }
33172 3127 }
33173 82 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
33174 3209 }
33175 17372 }
33176
4/4
✓ Branch 0 taken 9141 times.
✓ Branch 1 taken 10162 times.
✓ Branch 2 taken 7638 times.
✓ Branch 3 taken 1503 times.
19303 if(movedx || movedy)
33177 {
33178
2/2
✓ Branch 0 taken 14583 times.
✓ Branch 1 taken 3217 times.
17800 if(cmb->usrflags&cflag1)
33179 3217 is_conveyor_stunned = rate;
33180
2/2
✓ Branch 0 taken 17550 times.
✓ Branch 1 taken 250 times.
17800 if(cmb->usrflags&cflag3)
33181 {
33182
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 74 times.
250 if(abs(deltax) > abs(deltay))
33183 176 conv_forcedir = dir = (deltax > 0) ? right : left;
33184 74 else conv_forcedir = dir = (deltay > 0) ? down : up;
33185 250 }
33186 17800 }
33187 }
33188 19462 }
33189 14307770 }
33190
33191 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
33192 {
33193 DivineProtectionShieldClk=newclk;
33194
33195 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
33196 {
33197 // TODO(crash): check that .add succeeds.
33198 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
33199 decorations.spr(decorations.Count()-1)->misc=0;
33200 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
33201 decorations.spr(decorations.Count()-1)->misc=1;
33202 }
33203 }
33204
33205 36023 int32_t HeroClass::getDivineProtectionShieldClk()
33206 {
33207 36023 return DivineProtectionShieldClk;
33208 }
33209
33210 21 int32_t HeroClass::getHoverClk()
33211 {
33212 21 return hoverclk;
33213 }
33214
33215 26317048 int32_t HeroClass::getHoldClk()
33216 {
33217 26317048 return holdclk;
33218 }
33219
33220 8411508 int32_t HeroClass::getLastLensID(){
33221 8411508 return last_lens_id;
33222 }
33223
33224 210 void HeroClass::setLastLensID(int32_t p_item){
33225 210 last_lens_id = p_item;
33226 210 }
33227
33228 106172465 bool HeroClass::getOnSideviewLadder()
33229 {
33230 106172465 return on_sideview_ladder;
33231 }
33232
33233 370 void HeroClass::setOnSideviewLadder(bool val)
33234 {
33235
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 9 times.
370 if(val)
33236 {
33237 9 fall = fakefall = hoverclk = jumping = 0;
33238 9 hoverflags = 0;
33239 9 inair = false;
33240 9 }
33241 370 on_sideview_ladder = val;
33242 370 }
33243
33244 4675037 bool HeroClass::canSideviewLadder(bool down)
33245 {
33246
2/2
✓ Branch 0 taken 4630796 times.
✓ Branch 1 taken 44241 times.
4675037 if(!isSideViewHero()) return false;
33247
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 17780 times.
44241 if(jumping < 0) return false;
33248
2/2
✓ Branch 0 taken 15182 times.
✓ Branch 1 taken 11279 times.
26461 if (down)
33249 {
33250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11279 times.
11279 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, true))
33251 {
33252 return false;
33253 }
33254 11279 }
33255
3/4
✓ Branch 0 taken 11279 times.
✓ Branch 1 taken 15182 times.
✓ Branch 2 taken 11279 times.
✗ Branch 3 not taken.
26461 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
33256 {
33257 bool onSolid = on_sideview_solid_oldpos(this,true);
33258 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
33259 }
33260 //Are you presently able to climb a sideview ladder?
33261 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
33262 //y+0 checks your top-half for large hitbox; y+8 for small
33263 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
33264 //y+16 check is for going down onto a ladder you are standing on.
33265
2/2
✓ Branch 0 taken 25839 times.
✓ Branch 1 taken 622 times.
52300 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
33266
3/4
✓ Branch 0 taken 25839 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25831 times.
✓ Branch 3 taken 8 times.
25839 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
33267
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25831 times.
✓ Branch 2 taken 14552 times.
✓ Branch 3 taken 11279 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 11278 times.
37110 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
33268 4675037 }
33269
33270 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
33271 {
33272 if(!isSideViewHero()) return false;
33273 if(jumping < 0) return false;
33274 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
33275 {
33276 bool onSolid = on_sideview_solid_oldpos(this,true);
33277 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
33278 }
33279 //Are you presently able to climb a sideview ladder?
33280 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
33281 //y+0 checks your top-half for large hitbox; y+8 for small
33282 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
33283 //y+16 check is for going down onto a ladder you are standing on.
33284 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
33285 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
33286 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
33287 }
33288
33289 10010375 void HeroClass::execute(HeroClass::WalkflagInfo info)
33290 {
33291 10010375 int32_t flags = info.getFlags();
33292
33293
2/2
✓ Branch 0 taken 1770 times.
✓ Branch 1 taken 10008605 times.
10010375 if(flags & WalkflagInfo::CLEARILSWIM)
33294 1770 ilswim =false;
33295
2/2
✓ Branch 0 taken 10005265 times.
✓ Branch 1 taken 3340 times.
10008605 else if(flags & WalkflagInfo::SETILSWIM)
33296 3340 ilswim = true;
33297
33298
1/2
✓ Branch 0 taken 10010375 times.
✗ Branch 1 not taken.
10010375 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
33299 {
33300 charging = 0;
33301 attackclk = 0;
33302 }
33303
33304
1/2
✓ Branch 0 taken 10010375 times.
✗ Branch 1 not taken.
10010375 if(flags & WalkflagInfo::SETDIR)
33305 {
33306 dir = info.getDir();
33307 }
33308
33309
2/2
✓ Branch 0 taken 10009087 times.
✓ Branch 1 taken 1288 times.
10010375 if(flags & WalkflagInfo::SETHOPCLK)
33310 {
33311 1288 hopclk = info.getHopClk();
33312 1288 }
33313
33314
2/2
✓ Branch 0 taken 10008931 times.
✓ Branch 1 taken 1444 times.
10010375 if(flags & WalkflagInfo::SETHOPDIR)
33315 {
33316 1444 hopdir = info.getHopDir();
33317 1444 }
33318
33319 10010375 }
33320
33321 17803273 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
33322 {
33323 17803273 HeroClass::WalkflagInfo ret;
33324 17803273 ret.newhopclk = newhopclk;
33325 17803273 ret.newdir = newdir;
33326
2/2
✓ Branch 0 taken 14799327 times.
✓ Branch 1 taken 3003946 times.
17803273 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
33327
33328 17803273 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
33329 17803273 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
33330 17803273 ret.flags = flags1 | flags2;
33331 17803273 return ret;
33332 }
33333
33334 219038 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
33335 {
33336 219038 HeroClass::WalkflagInfo ret;
33337 219038 ret.newhopclk = newhopclk;
33338 219038 ret.newdir = newdir;
33339
1/2
✓ Branch 0 taken 219038 times.
✗ Branch 1 not taken.
219038 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
33340
33341 219038 ret.flags = flags & other.flags;
33342 219038 return ret;
33343 }
33344
33345 219038 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
33346 {
33347 219038 HeroClass::WalkflagInfo ret;
33348 219038 ret.newhopclk = newhopclk;
33349 219038 ret.newdir = newdir;
33350 219038 ret.newhopdir = newhopdir;
33351
33352 219038 ret.flags = flags ^ UNWALKABLE;
33353 219038 return ret;
33354 }
33355
33356 void HeroClass::explode(int32_t type)
33357 {
33358 static int32_t tempx, tempy;
33359 static byte herotilebuf[256];
33360 int32_t ltile=0;
33361 int32_t lflip=0;
33362 unpack_tile(newtilebuf, tile, flip, true);
33363 memcpy(herotilebuf, unpackbuf, 256);
33364 tempx=Hero.getX();
33365 tempy=Hero.getY();
33366 for(int32_t i=0; i<16; ++i)
33367 {
33368 for(int32_t j=0; j<16; ++j)
33369 {
33370 if(herotilebuf[i*16+j])
33371 {
33372 if(type==0) // Twilight
33373 {
33374 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 0, 0, (zc_oldrand()%8)+i*4));
33375 int32_t k=particles.Count()-1;
33376 particle *p = (particles.at(k));
33377 p->step=3;
33378 }
33379 else if(type ==1) // Sands of Hours
33380 {
33381 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 1, 2, (zc_oldrand()%16)+i*2));
33382 int32_t k=particles.Count()-1;
33383 particle *p = (particles.at(k));
33384 p->step=4;
33385
33386 if(zc_oldrand()%10 < 2)
33387 {
33388 p->color=1;
33389 p->cset=0;
33390 }
33391 }
33392 else
33393 {
33394 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 6, herotilebuf[i*16+j], zc_oldrand()%96));
33395
33396 int32_t k=particles.Count()-1;
33397 particle *p = (particles.at(k));
33398 p->angular=true;
33399 p->angle=zc_oldrand();
33400 p->step=(((double)j)/8);
33401 p->yofs=Hero.getYOfs();
33402 }
33403 }
33404 }
33405 }
33406 }
33407
33408 2224 void HeroClass::SetSwim()
33409 {
33410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
2224 if (CanSideSwim())
33411 {
33412 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
33413 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
33414 if (get_qr(qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
33415 }
33416 2224 else {action=swimming; FFCore.setHeroAction(swimming);}
33417 2224 }
33418
33419 123544 void HeroClass::SetAttack()
33420 {
33421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123544 times.
123544 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
33422 123544 else {action=attacking; FFCore.setHeroAction(attacking);}
33423 123544 }
33424
33425 136176140 bool HeroClass::IsSideSwim()
33426 {
33427
6/12
✓ Branch 0 taken 136176140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136176140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136176140 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 136176140 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 136176140 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 136176140 times.
136176140 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
33428 }
33429
33430 2782653 bool HeroClass::CanSideSwim()
33431 {
33432
1/2
✓ Branch 0 taken 2782653 times.
✗ Branch 1 not taken.
2782653 return (isSideViewHero() && get_qr(qr_SIDESWIM));
33433 }
33434
33435 12961106 int32_t HeroClass::getTileModifier()
33436 {
33437 12961106 return item_tile_mod() + bunny_tile_mod();
33438 }
33439 void HeroClass::setImmortal(int32_t nimmortal)
33440 {
33441 immortal = nimmortal;
33442 }
33443 void HeroClass::kill(bool bypassFairy)
33444 {
33445 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
33446 }
33447 45449294 bool HeroClass::sideview_mode() const
33448 {
33449
3/4
✓ Branch 0 taken 976059 times.
✓ Branch 1 taken 44473235 times.
✓ Branch 2 taken 976059 times.
✗ Branch 3 not taken.
45449294 return isSideViewHero() && (moveflags & move_obeys_grav) && !toogam;
33450 }
33451 18082 bool HeroClass::is_unpushable() const
33452 {
33453 18082 return toogam;
33454 }
33455
33456 416 HeroClass Hero;
33457